2
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 suggest why because I can't understand my existing code which is what?

gnat
  • 6,213
  • 108
  • 53
  • 73
bhas
  • 49
  • 2
  • I Q< S... is syntax error, I Q<[something] would be better (in MUMPS expressions must contain no spaces). See my answer about MUMPS syntax. – ern0 Aug 19 '13 at 20:21

2 Answers2

3

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.
gnat
  • 6,213
  • 108
  • 53
  • 73
David
  • 31
  • 2
2

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).

ern0
  • 3,074
  • 25
  • 40