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

Using Position function


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 05, 2012 5:04 pm
Reply with quote

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
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:12 pm
Reply with quote

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
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 05, 2012 5:17 pm
Reply with quote

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
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:20 pm
Reply with quote

Thank you for more complete logic.

So what is the problem?

I left my crystal ball at home.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Apr 05, 2012 5:25 pm
Reply with quote

the logic is to get a record written twice if both conditions are true icon_cool.gif
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Thu Apr 05, 2012 5:27 pm
Reply with quote

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
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:37 pm
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu Apr 05, 2012 6:42 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Apr 05, 2012 8:25 pm
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu Apr 05, 2012 9:35 pm
Reply with quote

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
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
Search our Forums:

Back to Top