Page 1 of 1

How to delete four lines

PostPosted: Tue Apr 15, 2014 11:31 pm
by samurai
Hello,

I have tried deleting a single line and wrote into another pds using if statement as

if (index(recd.i,SORT) > 0 ) then

....

i need to delete in all the members of same pds so it need to go in loop? If so what condition, please let me know....

also i have used two if statement to find a word in single line, but can someone let me know to delete some 4 lines as below:

SORT SYSIN
DD ALLOC
DSN ='....'
UNIT =TAPE



Please let me know to continue further to delete from SORT to UNIT = TAPE

Thanks!

Re: How to delete four lines

PostPosted: Wed Apr 16, 2014 3:16 am
by Pedro
Your question is not clear, but I think you want to skip a process for several consecutive lines. How about using a state indicator that you turn on and off?

1. default setting is on
...
2. turn off when you find the first record
3. If (on) then process record
4. turn on when you find the last record.

Re: How to delete four lines

PostPosted: Wed Apr 16, 2014 11:13 am
by samurai
Yeah Pedro Thanks!

I was trying to skip some 4 lines and if founf i will skip those by not writing into file as simply giving Do...End as empty like,

if (index(recd.i,SORT) > 0 ) then
DO
END
else
write record

ON & OFF i didnt try... let me try this...

Re: How to delete four lines

PostPosted: Wed Apr 16, 2014 2:56 pm
by NicC
2 ways to change what you have:

if (index(recd.i,SORT) > 0 ) then
NOP
else
write record

or
if (index(recd.i,SORT) = 0 )
then write record

Re: How to delete four lines

PostPosted: Wed Apr 16, 2014 7:57 pm
by samurai
Hi Pedro,

could you help me in getting the syntax. Thanks!

Re: How to delete four lines

PostPosted: Wed Apr 16, 2014 9:12 pm
by Pedro
I can help a little bit. My main suggestion was about a state indicator. Basically, if an IF statement is true, the THEN clause is performed. And true is indicated by a numeric 1. A false is a zero.

My suggestion had four bullets:

1. default setting is on
usethis = 1

...
Do steps 2-4 in a loop.
2. turn off (set to zero) when you find the first record

3. If (on) then process record
If (usethis) Then
   Write record...


4. turn on (set to one) when you find the last record.