Input file line number (N-1) and (N+3) copy



IBM's Command List programming language & Restructured Extended Executor

Input file line number (N-1) and (N+3) copy

Postby ankushgattani » Thu Sep 27, 2012 11:49 am

Hi,

i am trying to build a REXX, which does the following:
Find for 'XYZ' in the input file. lets say it was found in Nth line.
Then I've to copy (N-1)th and (N+3)th line to my output file.
I've to perform the copy operation for each occurence of 'XYZ' in the input file.
'XYZ' will always occur at 70th cloumn, if it occurs.

I am trying to read the input file line by line.
but not sure how to go about (N-1) and (N+3) lines.
ankushgattani
 
Posts: 30
Joined: Wed Aug 29, 2012 12:20 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Input file line number (N-1) and (N+3) copy

 

Re: Input file line number (N-1) and (N+3) copy

Postby NicC » Thu Sep 27, 2012 4:50 pm

before reading your next line save your last line that way you have n-1 in a save area. then read 3 more lines and you are at n+3. Write save area and current line. Simple?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Input file line number (N-1) and (N+3) copy

Postby expat » Fri Sep 28, 2012 10:43 am

Stem variables would appear to be the quickest and easiest solution

These users thanked the author expat for the post:
ankushgattani (Mon Jun 09, 2014 12:39 pm)
expat
 
Posts: 382
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Input file line number (N-1) and (N+3) copy

Postby NicC » Fri Sep 28, 2012 11:46 am

Unless you have loadsa input - but define 'loadsa'
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Input file line number (N-1) and (N+3) copy

Postby ankushgattani » Fri Sep 28, 2012 3:52 pm

My input file has some 100s of records only.
ankushgattani
 
Posts: 30
Joined: Wed Aug 29, 2012 12:20 pm
Has thanked: 3 times
Been thanked: 0 time

Re: Input file line number (N-1) and (N+3) copy

Postby NicC » Sat Sep 29, 2012 12:31 am

In that case one execution of EXECIO to read all the data into a stem then you can refer to stemname.n, stemname.n-1 and stemname.n+2. OK best to use proper variable names for n-1 and n+2 - n_minus_one and n_plus_2 would be fine. n_minus_one = n - 1 etc
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
ankushgattani (Mon Jun 09, 2014 12:39 pm)
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post