Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Win32::OLE and lvalue issue

by mercutio_viz (Scribe)
on Jun 15, 2005 at 06:15 UTC ( [id://466805]=perlquestion: print w/replies, xml ) Need Help??

mercutio_viz has asked for the wisdom of the Perl Monks concerning the following question:

Perl Monks,

I am blessed/cursed with being in a M$ environment for a particular project. I am using Perl to automate a terminal emulator that accesses a legacy system. The host system is a 3270 mainframe. My terminal emulator is SmarTerm (ST) by Esker.

The ST macro language and OLE objects are very rich, which is why I chose this piece of software. I was initially doing this work in VB6 but I scrapped that the moment I heard of Win32::OLE!

Here's my problem: the ST objects have a number of properties that are set as lvalues. For example, there is a timeout setting, the number of seconds that the program will sit and wait for one or more strings to be sent by the host. In VB6 you'd code it like this:

st.StringWait = 20 ' set timeout to 20 seconds ' Where 'st' the SmarTerm session object
"StringWait" is a property of the ST object. As you can see, it is on the left side of the = sign. In Perl you can't do this:
$st->StringWait = 20; # lvalue error! # Where '$st' is the SmarTerm session object
I've already tried this, just for kicks:
$st->StringWait(20); # compiles ok but no effect

Is there a Perl way of interfacing with these OLE objects that are traditionally set by using an lvalue?

Your insights and comments are welcomed and appreciated!

-MC

Replies are listed 'Best First'.
Re: Win32::OLE and lvalue issue
by ikegami (Patriarch) on Jun 15, 2005 at 06:18 UTC

    Properties are accessed as hash elements. Try $st->{'StringWait'} = 20;

      Ikegami,

      That is exactly what I figured out by looking at the article on Perl.com about automating MS Word! Your suggestion was exactly correct.

      BTW, can you tell me where you learned that piece of information? Just curious. Also, thanks for the quick reply! I was coming back to say that I had figured it out but you had already responded.

      -MC

        FYI, my bad for not reading my books thoroughly!

        The poop on getting and setting properties is found (among other places) in Perl In A Nutshell in section 23.2. Sorry to bother...

        -Slightly Embarrassed Perl Initiate

        can you tell me where you learned that piece of information?

        From the pod. It's not properly documented, but it's there under LetProperty:

        In Win32::OLE property assignment using the hash syntax is equivalent to the Visual Basic Set syntax (by reference assignment):

        $Object->{Property} = $OtherObject;

        corresponds to this Visual Basic statement:

        Set Object.Property = OtherObject

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://466805]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (None)
    As of 2024-04-25 01:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found