Page 1 of 1

to find more than one string which is in different positions

PostPosted: Sat Oct 30, 2010 12:55 am
by infy
Is it possible to use AND ,OR,XOR,NOR operations to search strings in a rexx commmand ?

Eg:
input:
03 123 NAME1 ADDR1
16 144 NAME2 ADDR2
02 123 NAME1 ADDR2

Required output :
03 123 NAME1 ADDR1
02 123 NAME1 ADDR1

in general we give as F '12365' (position)

All I wanted is, when I give F'123' (position1) 'name1' (position2) then I must get then desired output

Re: to find more than one string which is in different positions

PostPosted: Sat Oct 30, 2010 1:08 am
by dick scherrer
Hello,

You could possibly implement a macro to do this, but then you would need to write the macro. Depends on how many places you want to use this.

Either way, you can find the first value and when there is a "hit", find the second value. When the second value also is a "hit", write the output.

in general we give as F '12365' (position)
I don't understand how this relates to the question. . .

Re: to find more than one string which is in different positions

PostPosted: Wed Nov 10, 2010 7:27 pm
by infy
Can you please tell me on how to seach a string in a pds in a particular column. Also could you please suggest me some websites where i can learn the basics of rexx?

Re: to find more than one string which is in different positions

PostPosted: Wed Nov 10, 2010 8:02 pm
by MrSpock
At a basic level, if you have a variable in REXX, and you want to find a string in a specific position, then the POS function would give you what you want.

Another method would be to use the very powerful PARSE instruction, which is something you'll need to learn at some point anyway. You can parse a variable into tokens on specific offsets.

Given your original example, let's say I have the variable rec that contains:

----+----1----+----2
03 123 NAME1 ADDR1 


I could code:

fnd1 = Pos('123',rec)
fnd2 = Pos('NAME1',rec)

and then I could check for:

If fnd1 = 4 & fnd2 = 8 Then ... do something if both are present ...


or, using a PARSE:

Parse Var rec fld1 4 fld2 8 fld3 14 fld4   
If fld2 = '123 ' & fld3 = 'NAME1 ' Then ... do something if both are present ...


You can try this website for some REXX tutorials:

Classic Rexx Tutorial.