When writing a macro, I have a variable, {$#2}, that either starts with a 1 or 2 digit number followed by a ".", or it doesn't. When it starts in that way, I want to put the number into a rexxvar, which I have called C.

I have tried

#if [ DATATYPE(LEFT({$#2},1), "W") ] \#evaluate ^^ ^parse '{$#2} C '.' .^ \#endif \

This, and every variation I can think of, gives errors saying the #IF line contains invalid characters.

How should I do this?

I am using PPWizard, and Regina - but I can't create either tag.

ThanksIan

2

Best Answer


I do not use PPWizard so this could all be wrong, but

Looking at PPWizard #if, the if should be either

#if DATATYPE(LEFT({$#2},1), "W") 

or

#if [ DATATYPE(LEFT({$#2},1), "W") <> 0 ] 

But I do not know wether you can imbed the {$#2} or not (I do not know PPWizard)


For the parse statement one of these may be what you want

#evaluate ^^ ^parse value '{$#2}' with C '.' .^ 

or

#evaluate ^^ ^parse var {$#2} C '.' .^ 

See rexx parse syntax


An alternative way might try the Define Rexx tag and do it in rexx. More people could help you with pure rexx. i.e the rexx would be

if DATATYPE(LEFT(value_to_process,1), "W") then doparse var value_to_process C '.'end

where value_to_process is the value to be checked (i.e. {$#2})

For others. The final answer to the problem is to write

#RexxVar value_to_process = {$#2} #evaluate+ ^^ ^if DATATYPE(LEFT(value_to_process,1), "W") then do; parse var value_to_process C '.'; end^ \

in the macro I was creating.

Thanks Bruce. Your reply was most helpful on my route to a solution.