Files and Rexx



IBM's Command List programming language & Restructured Extended Executor

Files and Rexx

Postby MartinN » Thu Jul 10, 2008 10:38 pm

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
MartinN
 
Posts: 2
Joined: Thu Jul 10, 2008 10:35 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files and Rexx

Postby MrSpock » Thu Jul 10, 2008 11:06 pm

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
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: Files and Rexx

Postby MartinN » Fri Jul 11, 2008 12:51 am

Many thanks! It worked perfectly for me!
MartinN
 
Posts: 2
Joined: Thu Jul 10, 2008 10:35 pm
Has thanked: 0 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post