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
 

 

Using Position function

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

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Thu Apr 05, 2012 5:04 pm    Post subject: Using Position function
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: 645
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:12 pm    Post subject:
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: 90
Location: Chennai

PostPosted: Thu Apr 05, 2012 5:17 pm    Post subject: Reply to: Using Position function
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: 645
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:20 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Apr 05, 2012 5:25 pm    Post subject: Reply to: Using Position function
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: 90
Location: Chennai

PostPosted: Thu Apr 05, 2012 5:27 pm    Post subject: Reply to: Using Position function
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: 645
Location: Pennsylvania

PostPosted: Thu Apr 05, 2012 5:37 pm    Post subject:
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

Senior Member


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

PostPosted: Thu Apr 05, 2012 6:42 pm    Post subject: Reply to: Using Position function
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: 1219
Location: Israel

PostPosted: Thu Apr 05, 2012 8:25 pm    Post subject: Re: Reply to: Using Position function
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

Senior Member


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

PostPosted: Thu Apr 05, 2012 9:35 pm    Post subject: Reply to: Using Position function
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    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. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


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