Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Rexx Variable Substitution with POS command

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Jul 07, 2011 7:21 pm    Post subject: Rexx Variable Substitution with POS command
Reply with quote

I can not get a substitution variable to work using the POS command
and have seen nothing in the manulas telling me that I can not do this.

Has anyone done this..????? It works fine with other commands.

genlvl = '&gen040'||'='

genver = pos('"genlvl"',text)
Back to top
View user's profile Send private message

daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 662
Location: Pennsylvania

PostPosted: Thu Jul 07, 2011 7:29 pm    Post subject:
Reply with quote

I would run the exec with a TRACE(I) just before the code in question.

A TRACE(0) just afterwards will stop the clutter.

There looks like lots of quotes (and double quotes) confusing things.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Thu Jul 07, 2011 7:44 pm    Post subject: Reply to: Rexx Variable Substitution with POS command
Reply with quote

no reason not to work if coded correctly,
variable needles and haystacks are most common in non basic REXX parsing!

rather than debugging Your code ( clear as mud, I dare to say icon_biggrin.gif )

here is working snippet , which correctly return 6


Code:
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"                                                               
 000005                                                                         
 000006 Parse Source _sys _how _cmd .                                           
 000007                                                                         
 000008 text   = ".....&GEN040=..."                                             
 000009 genlvl = '&GEN040' || '='                                               
 000010 say pos(genlvl,text)                                                   
 000011                                                                         
 000012 Exit 0                                                                 
 000013                                                                         


tested and working

given the scarce info provided that' s the best I can do
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2038
Location: Silicon Valley

PostPosted: Thu Jul 07, 2011 8:10 pm    Post subject: Reply to: Rexx Variable Substitution with POS command
Reply with quote

Quote:
I can not get a substitution variable to work


Are you expecting the ampersand to resolve and substitute the variable?

It seems like you want this to work:
Code:
gen040 = 'testlvl'
genlvl = '&gen040'||'='

genver = pos('"genlvl"',text)


If you want it to be treated as a variable, do not use quotes:
Code:
gen040 = 'testlvl'
genlvl = gen040 ||'='

genver = pos('"genlvl"',text)
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Jul 07, 2011 8:14 pm    Post subject: Reply to: Rexx Variable Substitution with POS command
Reply with quote

GENVER = GENIDS||'='
"&GEN040="

517 *-* say 'text='text
>>> "text=//WSS820P1 PROC GEN040='+1',
"
text=//WSS820P1 PROC GEN040='+1',


518 *-* GENBEG = POS(GENVER,TEXT)
>>> "0"

As you can see this did not return the position 0, this is
the only time I have had problems using the POS command.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Thu Jul 07, 2011 8:21 pm    Post subject: Reply to: Rexx Variable Substitution with POS command
Reply with quote

a zero position is the proper result when searching for ( needle )
Code:
&GEN040=


and the strings being searched ( haystack) does not contain it
as per
Code:
text=//WSS820P1 PROC GEN040='+1',   
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Jul 07, 2011 8:27 pm    Post subject:
Reply with quote

enrico,

You are so right.... and I am blind as a BAT and just as tired, as I said
I have never had any trouble using the pos and substitution before, so
I was trying the different combo's with command. It was not until your
reply I see just what was wrong and what I was checking for......

Thanks once again from this tired old dog............. icon_lol.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Thu Jul 07, 2011 8:30 pm    Post subject: Reply to: Rexx Variable Substitution with POS command
Reply with quote

don' t worry, it happens!
and what' s wrong with old dogs anyway...
I bet I am older than You icon_biggrin.gif
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Jul 07, 2011 8:32 pm    Post subject:
Reply with quote

I have been doing this for 42 years just to give you and Idea of my age
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us