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

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.

Replies are listed 'Best First'.
Re^5: Interact with mainframe screen
by Corion (Patriarch) on Jun 13, 2007 at 14:31 UTC

    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.

      I realize that I have a ton to learn about object oriented programming. My only perl experience has been a more linear use of the language where I read and modify/create text files. Below is the code that you posted on reading the screen. Line two is the line that concerns me....

      my ($self) = @_;

      Thanks again for your patience.

      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; };

        The ->screen subroutine is to be called like this:

        my $host = Host::PCom->new($hostname); my @lines = $host->screen();