Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Error in SUBSTR function of CLIST

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

New User


Joined: 25 Feb 2008
Posts: 12
Location: Pune

PostPosted: Wed Feb 27, 2008 6:44 pm    Post subject: Error in SUBSTR function of CLIST
Reply with quote

I have the following statement in my CLIST:

IF &SUBSTR(1:3,&STR(&Z)) = &STR(XYZ) THEN +
CNT = CNT + 1

When I execute this CLIST I am prompted with the following message. Could you please tell me what mistake I have made here?
Contents of Z are : XYZ LMN ABC

IF &SUBSTR(1:3,?) = XYZ THEN
THIS STATEMENT HAS AN INVALID &SUBSTR RANGE OR EXIT CODE EXPRESSION
Back to top
View user's profile Send private message

cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Wed Feb 27, 2008 7:52 pm    Post subject: Reply to: Error in SUBSTR function of CLIST
Reply with quote

Wouldn't you need to use something like this where the statement does not started in position 1.

Code:

    SET &CNT = &CNT + 1
Back to top
View user's profile Send private message
Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Wed Feb 27, 2008 10:46 pm    Post subject:
Reply with quote

Do a WRITE of the &Z variable to be sure it has the value you expect.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Feb 28, 2008 4:20 am    Post subject:
Reply with quote

Hi,
you say the content of Z is XYZ LMN ABC, then where does the ? come from, &Z expects minimum of 3 characters.


Gerry
Back to top
View user's profile Send private message
Nikhil Bhole

New User


Joined: 25 Feb 2008
Posts: 12
Location: Pune

PostPosted: Thu Feb 28, 2008 10:11 am    Post subject:
Reply with quote

So my corrected syntax would be:

IF &SUBSTR(1:3,&STR(&Z)) = &STR(XYZ) THEN +
SET &CNT = &CNT + 1

Please correct me if this is wrong.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Feb 28, 2008 11:31 am    Post subject:
Reply with quote

Hi,
as long as &Z is at least 3 bytes long

Gerry
Back to top
View user's profile Send private message
Nikhil Bhole

New User


Joined: 25 Feb 2008
Posts: 12
Location: Pune

PostPosted: Thu Feb 28, 2008 11:42 am    Post subject:
Reply with quote

Thanks. I think I am finally getting a hang of this icon_biggrin.gif
Back to top
View user's profile Send private message
Nikhil Bhole

New User


Joined: 25 Feb 2008
Posts: 12
Location: Pune

PostPosted: Thu Feb 28, 2008 12:57 pm    Post subject: Syntax of PARSE VAR in REXX
Reply with quote

date1 = 20071212
PARSE VAR date1 . 3 yy 5 mm 7 dd

Could you please explain to me what the above statement would do? icon_cry.gif
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Thu Feb 28, 2008 9:07 pm    Post subject:
Reply with quote

No response means you should have started a new thread...

the 3, 5 and 7 are column numbers.
the command will parse and split the variable "date1" (this variable stays unchanged).

everything before col 3 will be placed in ".", which means will stay unassigned.
data from col 3 (included) to 5 (excluded) will be placed in var "yy"
data from col 5 (included) to 7 (excluded) will be placed in var "mm"
data from col 7 (included) to the end will be placed in var "dd"

after executing, yy contains 07, mm = 12 and dd 12
The "." is a placeholder and means you are not interested in keeping the value found at this perticuliar place.
Back to top
View user's profile Send private message
Nikhil Bhole

New User


Joined: 25 Feb 2008
Posts: 12
Location: Pune

PostPosted: Fri Feb 29, 2008 9:55 am    Post subject:
Reply with quote

It works. Awesome icon_smile.gif
Back to top
View user's profile Send private message
u770624

New User


Joined: 12 Jul 2006
Posts: 2
Location: Blighty

PostPosted: Tue Mar 04, 2008 3:51 am    Post subject:
Reply with quote

&Z is reserved and always null
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
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm
No new posts Reply MQ open error Vignesh Sid COBOL Programming 6 Thu Sep 07, 2017 6:02 pm
No new posts Error in SQL-PLIST3 'Above value tru... rikdeb DB2 4 Wed Sep 06, 2017 1:34 pm
No new posts WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us