Guidance Forums / Reginald Rexx / Array tail

Search 搜索
Home Home

Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Array tail
Posted by: guidance 2002-11-05 11:28:40
Reginald doesn't support direct string as array tail (subscript)?

I write:
SAY const.'crlf'
The output (OOOh, I can't copy the contents in output console window of RexxEd to paste here either!):


If I write:
SAY const.crlf
The output is correct ('old').

I understand the later one is equivalent with:
SAY const.crlf
but can't understand the behaviour of the first example (no any error reported).
Message2. Re: Array tail
Posted by: 2002-11-05 15:19:27
You can't use quotes in tail names. So REXX is interpreting

const.'crlf' the value of the stem variable named const. (which is here the default of CONST.) joined with the literal string 'crlf'. It doesn't see the = sign as a variable assignment because there isn't *only* a variable name on the left side of the = sign. You've got a variable joined with a literal string. That's an operation, not a variable name. So how does REXX regard the = sign? It regards it as a comparison test. It is checking the value of a combined string of "CONST.crlf" to the literal string 'old'. It's as if you typed:

'CONST.crlf' = 'old'

And the value of this expression is FALSE (ie, 0). So the result of this entire line is if you simply typed:


Now what does REXX do with a line that is simply the above? REXX doesn't know what else to do with this. And what does REXX do with a line it doesn't know what to do with? You guessed it. It sends it off to the shell. Run your script again (but not from RexxEd. RexxEd's console window isn't a real console, and so the shell doesn't display error messages to it). See that error message:

'0' is not recognized as an internal or external command.

Ok, so since your first line is not a variable assignment, that means you really haven't assigned any value to a variable named CONST.CRLF. And that's why when you SAY it, you get its default value.

In conclusion, if you want a variable assignment, then make sure you put only a variable name on the left side of the parentheses. And variable names do not contain quote characters.

By the way, are you trying to defeat "tail name substitution" just so you don't accidentally set the variable named CRLF to some value other than its own name? I think that a better alternative is to use a dollar sign as the first character of your tail name. And then never use a simple variable name that begins with a dollar sign. Here's an example:

const.$crlf = 'whatever'

Now, never use the variable $crlf in your script. You'll never have to worry about $crlf being substituted with anything else
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
© Wed 2024-5-29  Guidance Laboratory Inc. Hits:0