Page 1 of 1

Files and Rexx

PostPosted: Thu Jul 10, 2008 10:38 pm
by MartinN
Hi,

I'm very new to Rexx and I have the following task to do.

I have a file which contains data which causes errors on further processing. I would like to remove that data from the file and store it in another. The data begins with a certain pattern like eg. AB1FGZ. How could I do this?

Thanks for your help!

Regards,
Martin

Re: Files and Rexx

PostPosted: Thu Jul 10, 2008 11:06 pm
by MrSpock
First of all, let me go on record as stating that, since I don't know much about this file or your processing, I think this would be better handled by something else, like an EDIT or a SORT program.

That being said, there's a couple of options you could look into. You'd start by reading a record from the input dataset. Let's call the variable holding the record therec. FILEA will be the unmatched output, FILEB will be the matched output. Since you stated that the data you want to remove starts with a particular value, you can use the LEFT function to examine the 6 leftmost bytes of the data:

If LEFT(therec,6) = 'AB1FGZ' Then ... write to FILEB
Else ... write to FILEA

You can use the PARSE function:

PARSE VAR therec check 7 .
If check = 'AB1FGZ' Then ... write to FILEB
Else ... write to FILEA

You can use the POS function:

If POS( 'AB1FGZ',therec) = 1 Then ... write to FILEB
Else ... write to FILEA

Re: Files and Rexx

PostPosted: Fri Jul 11, 2008 12:51 am
by MartinN
Many thanks! It worked perfectly for me!