macoseditorsubroutinemumps

How to create a subroutine in MUMPS on Mac os X


I'm starting a project where I need to have some reading knowledge of MUMPs, the Massachusetts General Hospital Utility Multi-Programming System. I've managed to get it working on my OS X El Capitan computer. I can do some of the simple things, but cannot seem to create a simple subroutine. According to the specs that I can find, a subroutine is created by a label then followed by lines that start with a tab or blank and instructions, so that

HELLO
   WRITE "Hello, World!",!
   QUIT

would be a subroutine that I could invoke using

DO HELLO

When I try to enter it, it immediately executes the WRITE statement.

Also, many examples are of the form:

DEMO 
   Kill For i=1:1:10 SET Ary(i)=i*2
   DO Average Write !,"Average=",AVG
   KILL Ary,AVG,i
   QUIT
Average  SET Sum=0;
   ;  Do something here
   QUIT

When I start typing the DO Average line, I get an error that Average isn't defined.

Any ideas on how one enters the subroutine?


Solution

  • First of all between Kill and For, should be more then 1 space, and if it os only one space, then For became a variable and should be killed. Then you are were wrong when recognized UNDEFINED error for command DO Average, you have another UNDEFINED error in the same line and it is AVG variable, which is really undefined in your code.
    If you just in the begin of understanding MUMPS language, I would recommend to write every command on a separate line.