A variable is a convenient local memory storage location during the execution of a routine.
A Global is a persistent on disk storage location set, killed or changed during the execution of a routine.
A routine is a text file on disk that is compiled into a program.
These all share one thing in common. They can only have names of up to 31 characters long. Any longer and the mumps environment silently truncates the names for globals and variables.
GTM>Set testdatadata1231231231231231231=123
GTM>Set testdatadata12312312312312312319999=456
GTM>Write testdatadata1231231231231231231
456
GTM>
As you can see above there is actually only one variable "testdatadata1231231231231231231".
The same truncation behavior can be noted for globals
GTM>Set ^testdatadata1231231231231231231("a")=123
GTM>Set ^testdatadata12312312312312312319999("a")=456
GTM>Write ^testdatadata1231231231231231231("a")
456
GTM>
Above there is only one global defined "^testdatadata1231231231231231231("a")".
To demonstrate the truncation behaviour on routines. Create a routine called "testroutine12312312312312312312" with the following content:
T1
Write "123"
Quit
Create a second routine called "testroutine123123123123123123129999" with the following content:
T2
Write "456"
Quit
Now when you run either routine from the command line you will get the same response. Also note that only the line label "T1" is found:
GTM>D ^testroutine12312312312312312312
123
GTM>D ^testroutine123123123123123123129999
123
GTM>D T1^testroutine123123123123123123129999
123
GTM>D T2^testroutine123123123123123123129999
%GTM-E-LABELMISSING, Label referenced but not defined: T2
GTM>
Also in a given routine, a line label can only be distinguished up to 31 characters. Another factor of this line label name limit is that the compiler will not allow duplicate line labels to be defined within a single routine. So if two line labels do not differ in their first 31 characters they will be seen by the compiler to be a duplicate line labels.
GTM>D L234567891012345678910123456789^L234567891012345678910123456789
L2345678910123456789101234567890
^-----
At column 0, line 86, source module /gtm/rou/L234567891012345678910123456789.m
%GTM-E-MULTLAB, This label has been previously defined
31 characters is quite generous. In the days of MSM mumps the magic number was actually just 8.
... In the days when an expert used to be the person that remembered the difference between "HAD2^PS217Hgg" and "MAD2^PS217Hgg". :)
No comments:
Post a Comment