View previous topic :: View next topic
|
Author |
Message |
scorp_rahul23
New User
Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
I am trying to serach a number but its harcoded in position function. But When I am trying to remove this hardcode value it is throwing error.
Can anyone suggest what to do ?
Code: |
DO I = 1 TO MPRV.0
IF POS('0368083826601C'X,MPRV.I) <> 0 THEN
DO
PUSH MPRV.I
"EXECIO 1 DISKW MPROUT"
SAY "WRITTEN"
END
|
|
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Use the error message to diagnose the problem.
Also your END statements do not appear to match up (two DO and one END).
Unless of course you chose to give a snippet of code as incomplete as your problem description. |
|
Back to top |
|
|
scorp_rahul23
New User
Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
This is logic
Code: |
DO I = 1 TO MPRV.0
IF POS('0368083826601C'X,MPRV.I) <> 0 THEN
DO
PUSH MPRV.I
"EXECIO 1 DISKW MPROUT"
SAY "WRITTEN"
END
IF SUBSTR(MPRV.I,30,10) = " " THEN
DO
PUSH MPRV.I
"EXECIO 1 DISKW MPROUT"
SAY "WRITTEN"
CNT = CNT + 1
END
IF CNT = 2 THEN
EXIT
END
END
|
|
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Thank you for more complete logic.
So what is the problem?
I left my crystal ball at home. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the logic is to get a record written twice if both conditions are true |
|
Back to top |
|
|
scorp_rahul23
New User
Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
Problem is I am trying not to harcode the value in POS function. But that this is not wrkng.
Code: |
IF POS('0368083826601C'X,MPRV.I) <> 0 THEN
|
I am trying to replace this 0368083826601 with a variable but its not picking it
Code: |
('0368083826601C'X,MPRV.I)
|
Code: |
VAR1 = 0368083826601C
IF POS('VAR1'X,MPRV.I) <> 0 THEN
|
I am getting below error.
Code: |
13 +++ IF POS('VAR1'X
"
Error running ICNREAD, line 13: Invalid hexadecimal or binary string
***
|
|
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
How on earth was anybody going to answer your initial question without the additional information I had to pry out out you?
Now that we have enough to go on, try this:
Code: |
VAR1 = '0368083826601C'
VAR2 = X2C(VAR1)
IF POS(VAR2,MPRV.I) <> 0 THEN |
The piece that is still missing is exactly what does the data on the record look like your are trying to match.
I think this will work, but only you can tell us. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Code: |
VAR1 = 0368083826601C
IF POS('VAR1'X,MPRV.I) <> 0 THEN |
The reason your code did not work is because things within quotes are not considered variables. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
scorp_rahul23 wrote: |
This is logic
Code: |
DO I = 1 TO MPRV.0
IF POS('0368083826601C'X,MPRV.I) <> 0 THEN
DO
PUSH MPRV.I
"EXECIO 1 DISKW MPROUT"
SAY "WRITTEN"
END
IF SUBSTR(MPRV.I,30,10) = " " THEN
DO
PUSH MPRV.I
"EXECIO 1 DISKW MPROUT"
SAY "WRITTEN"
CNT = CNT + 1
END
IF CNT = 2 THEN
EXIT
END
END
|
|
Your indentation is wrong, which makes your program difficult to read.
scorp_rahul23 wrote: |
Code: |
IF POS('VAR1'X,MPRV.I) <> 0 THEN |
|
' 'X is not a function ! You cannot ' 'X a variable !!! |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
I think this code better matches the original hard-coded example:
Quote: |
var1 = '0368083826601C'X
IF POS(var1, MPRV.I) <> 0 THEN |
The difference is that the type is set during the assignment. |
|
Back to top |
|
|
|