in reply to Re: Interact with mainframe screen
in thread Interact with mainframe screen

Could specify where I would use my login information to log into the mainframe? Im guessing $connection_name = login and password? Whats the exact syntax? and what is $profile, is it a file it reads from or is it a variable I assign?

Replies are listed 'Best First'.
Re^3: Interact with mainframe screen
by Corion (Patriarch) on Apr 20, 2007 at 14:04 UTC

    The above code is only the package to launch the connection to the 3270 window, not to give any input to it. I recommend that you read the documentation that accompanies IBM Personal Communications to find out how to automate stuff within it. I won't post my complete code as much of it belongs to my employer I guess. You will then need to employ the methods to read what is on the screen and which fields are available for input. For example, I have the following subroutine in Host::PCom:

    sub screen { my ($self) = @_; my ($cols,$rows) = ($self->cols,$self->rows); my ($line) = $self->eclps->GetTextRect(1,1,$rows,$cols); my @lines; while ( $line =~ s/(^.{1,$cols})//sm) { push @lines, $1; }; s!\0! !g for @lines; # Mark fields as dirty $self->log("Fields marked dirty"); $self->{fields} = undef; push @lines, $line if $line; @lines; };

    It returns the current screen (resp. a cached version of it) as a list of scalars which my programs then check. I also have two routines for getting and setting input fields:

    sub get_set_field { my $self = shift; my $field = shift; my $result; if (defined wantarray) { $result = $field->GetText(); $self->log("value is $result"); carp( "get_set_field() called in void context without a value",2 ) + unless @_; }; if (@_) { $field->SetText(@_); $self->log("Setting field to @_"); }; $result; }; sub field_by_index { my $self = shift; my $index = shift; my @fields = $self->fields; my $field = $fields[ $index ]; $self->get_set_field($field,@_); };
      Hello, I have learned a ton about OLE from you guys but there is very little documentation on the internet about OLE as it pertains to PCOM so there arent may examples to study. Corion, yours is a great example but I have a few issues.

      1. package Host::PCOM; #<-what is the signifigance of this?

      2. my ($class,$connection_name) = @_; #<- changed this to $class = "pcsws" and $connection_name = "P"

      3. my $hostname = 'WSConfig'; #<-changed this to $hostname = "MFrame1.ws"

      So I can spawn the PCOM session successfully. But I get errors when I try to read the presentation space. I think the problem is that I dont know exactly what parameters to send to the screen sub for @_. I tried hard coding @_ to lots of different values, just guessing at it. Can you tell me what parameters you are passing to the sub. Error message below.....

      Error message - "Can't locate object method "cols" via package "P" (perhaps you forgot to load "P"?) at C:\(path snipped)\MFtest.pl line 76."

      4. my ($self) = "@_"; #<-What value is expected from @_?

      Thanks in advance for your help.

        Please learn about Perl packages. The package statement declares a package. You might want to read a short introduction into Perl Object Oriented Programming, maybe the perlboot or some other tutorial on the matter. Until you understand this, you won't understand what parameters are passed to the ->new() constructor.

        You don't show the relevant part of your failing code, so I cannot help you with your further problems. I guess that you have misunderstood my code or changed my code in some ways that make it not work anymore, but it's hard to tell without seeing any code.

        I didn't show you the implementation of the ->cols() subroutine. You will have to write it yourself. The PCOM subroutine to call is obvious from the PCOM documentation. You might also simply want to hardcode the value to 78, if all your terminal sessions have 78 columns.

        The line

        my ($self) = "@_";

        makes little sense. I don't find such a line in the code I posted, so this is an unrelated error introduced by you into code you did not show.

      So does this mean we need IBM Personal Communications in order for this to work? How much would this software cost?

        Have you tried contacting Tech. Support for the product you are using now?

        According to the chart close to the bottom of this page, Hummingbird support both 16-bit and 32-bit HLLAPIs, and comes with a programming language, macro editor and OLE library inteface. Although, it seems the latter is not compatible with the IBM PC3270 product.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.