Q ZR $ZTLP I Q=-1 S Q,A=F G T
I Q< S A=F G R
How to identify Label, Keyword and Variable in MUMPS?
What is Q in above code? i.e. Label, Variable or Key word?What are the rules to define variable keyword and subroutine?
Otherwise it is difficult to identify could you开发者_Go百科 suggest why because I can't understand my existing code which is what?Q
means QUIT
in first instance but then I Q=-1
is IF Q EQUALS -1
- Q
is a variable here too - not very good practice
S Q,A=F again SET Q and A = F
I Q< S A=F G R if Q is less than null (???) SET A=F then GOTO line R.
The secret is: whitespaces.
General MUMPS program line syntax is: ...
Lebel and arguments are optional: when a line has no label, it begins with tab, when a command has no arguments (it happens in rare cases, e.g.: Quit), the command is followed by two spaces.
When a line begins with command (no label and no tab), it's not part of a program, but it is an immediatelly executed command.
You may feel that it's confusing, but remember, MUMPS was designed when machines were slow; it's easy to parse commands if they are strictly delimited. That's why commands can be abbreviated as single-letter, and also that's why MUMPS have no operation precedence (newer MUMPS systems are configurable to use operator precedence instead of traditional left-to-right processing order).
精彩评论