View previous topic :: View next topic
|
Author |
Message |
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
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 )
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2594 Location: Silicon Valley
|
|
|
|
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 |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
a zero position is the proper result when searching for ( needle )
and the strings being searched ( haystack) does not contain it
as per
Code: |
text=//WSS820P1 PROC GEN040='+1', |
|
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
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............. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
don' t worry, it happens!
and what' s wrong with old dogs anyway...
I bet I am older than You |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
I have been doing this for 42 years just to give you and Idea of my age |
|
Back to top |
|
|
|