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

Error in SUBSTR function of CLIST


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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
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
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: 1702
Location: Australia

PostPosted: Thu Feb 28, 2008 4:20 am
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
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: 1702
Location: Australia

PostPosted: Thu Feb 28, 2008 11:31 am
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
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
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: 1353
Location: Israel

PostPosted: Thu Feb 28, 2008 9:07 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
Search our Forums:

Back to Top