to find more than one string which is in different positions



IBM's Command List programming language & Restructured Extended Executor

to find more than one string which is in different positions

Postby infy » Sat Oct 30, 2010 12:55 am

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
infy
 
Posts: 2
Joined: Sat Oct 30, 2010 12:39 am
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby dick scherrer » Sat Oct 30, 2010 1:08 am

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. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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

Postby infy » Wed Nov 10, 2010 7:27 pm

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?
infy
 
Posts: 2
Joined: Sat Oct 30, 2010 12:39 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby MrSpock » Wed Nov 10, 2010 8:02 pm

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


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post