1

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?

John Wooten
  • 685
  • 1
  • 6
  • 21
  • 1
    I don't see anything wrong in your code. But having limited time, I don't want to ask after why it isn't working. I would suggest asking on comp.lang.mumps. There are tons of people there who can help you. --Sam (Programmed in M for 8 years now). – Sam Habiel Apr 06 '16 at 05:14
  • 1
    What version of M/Mumps are you using? (Or is it really Caché ObjectScript?) – Scott Jones Apr 16 '16 at 17:59
  • I'm using Cache 2016.1, but I don't know if it's ObjectScript. I'm using it from the terminal and have a VistA CACHE.DAT file. I can't figure out how to get a listing of the executable functions in that file and can't figure out how to write one from the terminal and save it as a global. – John Wooten Apr 18 '16 at 15:43

1 Answers1

2

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.

DAiMor
  • 3,185
  • 16
  • 24
  • Thanks. This was a big help. Fixed that, then put code into a file and did: DO ^filename and it worked! On a quick note, how do I close an issue once I'm happy with the answer and "reward" the person answering? – John Wooten Apr 07 '16 at 14:32