IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Rexx Variable Substitution with POS command


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 792
Location: Pennsylvania

PostPosted: Thu Jul 07, 2011 7:29 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10875
Location: italy

PostPosted: Thu Jul 07, 2011 7:44 pm
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

Global Moderator


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

PostPosted: Thu Jul 07, 2011 8:10 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10875
Location: italy

PostPosted: Thu Jul 07, 2011 8:21 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10875
Location: italy

PostPosted: Thu Jul 07, 2011 8:30 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top