View previous topic :: View next topic
|
Author |
Message |
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
REXX stem default values
I entered the dialog below in trace mode.
In my opinion, after dropping "any_stem.19", its value should
return to the default value(any_value) and not the capitalized
symbol name(ANY_STEM.19) used for undefined sysmbols.
Does anyone know the internal workings of REXX.
Could it possibly keep a list of dropped symbols?
drop any_stem.
any_stem.="any_value"
say any_stem.19
any_value
say any_stem.any_tail
any_value
any_stem.19="Value for any_stem.19"
say any_stem.19
Value for any_stem.19
drop any_stem.19
say any_stem.19
ANY_STEM.19
any_stem.19=any_stem.
say any_stem.19
any_value |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
I think that you will find that the default value for any unitialised variable is the variable name.
By dropping the variable STEM.19 and then giving a SAY against that variable will say the unitialised value which is the variable name. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
suggest you read the REXX Users Guide for internal workings of REXX.
REXX is not case sensitive. Within the above reference, mention is made that without a lower-case requirement (' or "), display on the screen is upper-case, though your code maybe in lower- or mixed-case.
no, it does not keep a list of dropped variables; they would not be dropped.
REXX maintains variables and their values.
if an undefined variable is referenced, the variable is, as expat said, set to a value = to the variables name, and when display, it is upper-case. |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Also, take a look at the SYMBOL function. It can help you determine if a symbol was initialized (and therefore became a variable).
O. |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
Thanks for the trouble so far. But there is still
something I dont understand. Maybe the new example below
illustartes better what I mean. After dropping any_stem.2 and
any_stem.4 (which were never explicitly defined) then REXX symbol
function "knows" that they are LIT, insted of going back to show
undefined compound variables as "DEFAULT".
drop any_stem.
say any_stem.
ANY_STEM.
any_stem.="DEFAULT"
say any_stem.
DEFAULT
do idx=1 to 5;say symbol("any_stem."idx);end
VAR
VAR
VAR
VAR
VAR
drop any_stem.2
drop any_stem.4
do idx=1 to 5;say symbol("any_stem."idx);end
VAR
LIT
VAR
LIT
VAR |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Further, when a stem is used as the target of an assignment, all possible compound variables whose names begin with that stem receive the new value, whether they previously had a value or not. Following the assignment, a reference to any compound symbol with that stem returns the new value until another value is assigned to the stem or to the individual variable.
For example:
hole. = "empty"
hole.9 = "full"
say hole.1 hole.mouse hole.9
/* says "empty empty full" */
|
based on the above quote from z/OS V1R8.0 TSO/E REXX Reference 2.4.4 Stems
i would expect the following behavior, as you observed.
Code: |
any_stem.="DEFAULT"
say any_stem.
DEFAULT
do idx=1 to 5;say symbol("any_stem."idx);end
VAR
VAR
VAR
VAR
VAR
drop any_stem.2
drop any_stem.4
do idx=1 to 5;say symbol("any_stem."idx);end
VAR
LIT
VAR
LIT
VAR
|
z/OS V1R8.0 TSO/E REXX Reference 4.3.58 SYMBOL
VAR means an assignment was done
LIT means no assignment. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Welcome to the Forum!
Kurt Deininger wrote: |
In my opinion, after dropping "any_stem.19", its value should return to the default value(any_value) |
For you, "any_value" is the default value, but for REXX it is just a value.
And REXX is very specific about what the DROP instruction does:
TSO/E REXX Reference wrote: |
DROP "unassigns" variables, that is, restores them to their original uninitialized state. |
|
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
Thanks everybody,
I must now admit that REXX acts according to the manual,
but I was still puzzled how it knows that a particular
compound variable was dropped. I ran the code below, which
ends up with machine storage exhausted. This seems to me to
indicate that REXX stores the name of any compound variable
that was dropped, how else would you run out of storage by
basically doing nothing? Also proves the old line:
If all else fails, read the manual!
drop any_stem.
any_stem.="DEFAULT"
do idx=1 to 9999999
drop any_stem.idx
if idx//10000=0 then do
say"did="idx
end
end
did=10000
did=20000
did=30000
did=40000
did=50000
did=60000
did=70000
did=80000
did=90000
did=100000
did=110000
did=120000
did=130000
did=140000
did=150000
did=160000
did=170000
did=180000
did=190000
IRX0005I Error running ANYSTEM, line 12: Machine storage exhausted
*** |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
ok, I give.
in a discussion about DMSCDR which although VM, and is called by other than rexx languages,
PURPOSE:
Quote: |
Use the DMSCDR routine to cause a calling REXX exec to drop a single REXX variable or a group of REXX variables having the same stem. Dropping variables restores them to their original, uninitialized state. DMSCDR must be called from a program written in a language other than REXX. |
though the above is confusing (maybe), the applicable verbiage is:
Dropping variables restores them to their original, uninitialized state.
which I would interpret to mean,
once referenced, a variable name exists (stem in this discussion), whether DROPped or not. |
|
Back to top |
|
|
Kurt Deininger
New User
Joined: 13 Jul 2010 Posts: 19 Location: Frankfurt/Germany
|
|
|
|
OK then,
Thanks again everybody. It is my understanding that you are
meant to post a message that you are finished with the subject.
I could not find a button, so I guess you post an informal message.
If there is a procedure for closing a topic, someone let me know
please.
Cheers. Kurt |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
There is no formal way to close a thread, but it is appreciated when the poster lets us know that a point has been understood or the problem has been resolved. |
|
Back to top |
|
|
|