Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: iamaboringperson on July 31, 2006, 01:43:00 AM

Title: Problems with PARSE (Rexx)
Post by: iamaboringperson on July 31, 2006, 01:43:00 AM
Hi, I've been having troubles with the Rexx PARSE instruction.

When I want the first part of a string I get nothing.

EG.

Code: [Select]

BLAH="1.2.3"

PARSE VAR BLAH WITH num1'.'num2'.'num3

SAY NUM1 NUM2 NUM3

I get:

2 3

The only way I've been able to work around this, is to put something in front of the variable.

Like so:

Quote

BLAH="1.2.3"

BLAH_T='a'BLAH

PARSE VAR BLAH_T WITH 'a'num1'.'num2'.'num3

SAY NUM1 NUM2 NUM3


But this is inelegant, and it messes with the data. It's possible that depending on what data is coming in, it may not work.

Surely there is some way around this problem?

Thanks in advance if anybody can help me!
Title: Re: Problems with PARSE (Rexx)
Post by: Piru on July 31, 2006, 02:21:42 AM
@iamaboringperson
Quote
Surely there is some way around this problem?

As usual ARexx itself is ok, but your code is not. ARexx is very frustrating in this respect, it's so flexible it lets thru almost anything without error messages. :-)

Specifically:
Code: [Select]
PARSE VAR BLAH WITH num1'.'num2'.'num3
...is wrong. With that code the first value is assigned to variable called 'WITH'.

Either remove WITH or use:
Code: [Select]
PARSE VALUE BLAH WITH num1'.'num2'.'num3