View previous topic :: View next topic
|
Author |
Message |
Nikhil Bhole
New User
Joined: 25 Feb 2008 Posts: 12 Location: Pune
|
|
|
|
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 |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
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 |
|
|
Bill Dennis
Active Member
Joined: 17 Aug 2007 Posts: 562 Location: Iowa, USA
|
|
|
|
Do a WRITE of the &Z variable to be sure it has the value you expect. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
Nikhil Bhole
New User
Joined: 25 Feb 2008 Posts: 12 Location: Pune
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
as long as &Z is at least 3 bytes long
Gerry |
|
Back to top |
|
|
Nikhil Bhole
New User
Joined: 25 Feb 2008 Posts: 12 Location: Pune
|
|
|
|
Thanks. I think I am finally getting a hang of this |
|
Back to top |
|
|
Nikhil Bhole
New User
Joined: 25 Feb 2008 Posts: 12 Location: Pune
|
|
|
|
date1 = 20071212
PARSE VAR date1 . 3 yy 5 mm 7 dd
Could you please explain to me what the above statement would do? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Nikhil Bhole
New User
Joined: 25 Feb 2008 Posts: 12 Location: Pune
|
|
|
|
It works. Awesome |
|
Back to top |
|
|
u770624
New User
Joined: 12 Jul 2006 Posts: 2 Location: Blighty
|
|
|
|
&Z is reserved and always null |
|
Back to top |
|
|
|