Saturday, March 15, 2014

Your first GTM module

Let's create a module named 'hello' that can display 'world'.
  1. Start the client: mumps -dir
  2. Edit the file "hello": zed "hello"
  3. Write this code:  say w "hello",! q
  4. Save: :wq
  5. Compile: zl
  6. Run the code: d say^hello
  7. Enjoy !

The code in an indented version
say
  w "hello",!
  q
Here's the session:
#GTM] zed "hello"
[ INSIDE  YOUR $EDITOR ]
[ you save the file    ]
[ and quits the editor ]
#GTM] zl
#GTM] d say^hello
world

#GTM]

Some explanations:
say                   ; Name of the label
  w "hello",!         ; w[rite] the string "hello" followed by end of line: '!'
  q                   ; q[uit] return the control to the caller

You can use the fully qualified name for functions:
say                   ; Name of the label
  write "hello",!     ; w[rite] the string "hello" followed by end of line: '!'
  quit                ; q[uit] return the control to the caller

No comments:

Sticky