HP3000-L Archives

January 2002, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Thu, 31 Jan 2002 17:14:03 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (85 lines)
Suprtool has an IF but it doesn't have an ELSE, so it would take 26 passes.
You could do it in Perl, easily:
#!/PERL/PUB/perl -w

my %filehandle;

my ($cdc, $userid, $username, $letter);
my $f;
my $output;

while (<>) {
  $cdc      = substr($_, 0, 3);
  $userid   = substr($_, 3, 10);
  $username = substr($_, 13, 25);
  $letter   = substr($username, 0, 1);

  if ($cdc eq "ITC" && $letter =~ /[A-Z]/) {
    $output = "$cdc.$userid$username\n";
    if (not defined ($f = $filehandle{$letter})) {
      open $f, ">USERITC$letter" or die "Cannot open USERITC$letter: $!\n";
      $filehandle{$letter} = $f;
    }
    print $f $output
  }
}

This program assumes that the input is strictly ASCII (no embedded '\n'
characters), and it creates bytestream output files.  If either assumption
is wrong, you could use my MPE::File module.

You would run it from the shell as:
  perl prog.pl /ALERTS/IWIN/ITC




----- Original Message -----
From: "Born, Ken" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Thursday, January 31, 2002 4:32 PM
Subject: [HP3000-L] Suprtool question... Multiple outputs using Multiple
IF's


> Greetings,
> I am working on a suprtool process to be able to generate output files
based
> on the data in a file.
>
> !RUN SUPRTOOL.PUB.ROBELLE
>  INPUT ITC.IWIN.ALERTS
>  DEFINE CDC,1,3,CHAR
>  DEFINE USER-ID,4,10,CHAR
>  DEFINE USER-NAME,14,25,CHAR
>  EXTRACT CDC
>  EXTRACT "."
>  EXTRACT USER-ID
>  EXTRACT USER-NAME
>  IF CDC == "ITC" AND USER-NAME == "A@"
>    OUTPUT USERITCA,ASCII
> Now, If the If statement is false, I want to do another test and output
the
> record
> to USERITCB IF CDC == "ITC" AND USER-NAME == "B@"
>  XEQ
>  EXIT
>
> I attemtped several things but it won't let me use multiple IF's.  I know
I
> could probably
> copy the suprtool block again and replace the two lines with
> IF CDC == "ITC" AND USER-NAME == "B@"
>    OUTPUT USERITCB,ASCII
>
> But, I don't want a JCL that needs to read the file input file 26 times.
I
> was hoping for a cleaner way of doing it.
> thanks. in advance...
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2