Operating in Direct Mode

This section provides an overview of the following basic operational issues in Direct Mode:

Entering Direct Mode

To enter Direct Mode, type $gtm_dist/mumps -direct at the shell prompt.

$ $gtm_dist/mumps -direct

This shows using $gtm_dist/mumps -direct at the prompt to enter Direct Mode.

To create a gtm alias in your shell startup file (in the example below the startup file is assumed to be a .profile file):

  1. Open an edition session for your .profile file by typing:

    $vi .profile
  2. Add a function to the file to define your gtm alias:

    gtm(){ $gtm_dist/mumps -direct}
  3. save the file.

Now, when you want to enter Direct Mode for an editing or debugging session, simply type gtm at the shell prompt.


$ gtm

This shows that the gtm alias typed at the shell prompt also takes you to the Direct Mode.

Functionality Available in Direct Mode

This section provides an overview of basic functionality and concepts that enhance your use of Direct Mode.

Command Recall

Direct Mode includes a line command recall function to display previously entered command lines. Use <CTRL-B> or the Up Arrow key at the GTM> prompt to scroll back through command lines. Use the Down Arrow key to scroll forward through the command lines. GT.M displays one command line at a time.You may delete and reenter characters starting at the end of a recalled line.

The RECALL command is another way to access previously entered Direct Mode command lines. RECALL is only valid in Direct Mode and causes an error if it appears in other M code.

The format of the RECALL command is:

REC[ALL] [intlit|strlit]
  • The optional integer literal specifies a previously entered command by the counting back from the present.

  • The optional string literal specifies the most recently entered command line that starts with characters matching the (case-sensitive) literal.

  • When the RECALL command has no argument, it displays up to a maximum of 99 available past Direct Mode entries.

If the Direct Mode session has just started, you may not have entered 99 lines for GT.M to save and therefore you will not have 99 lines to look at. The most recently entered GT.M command line has the number one (1), older lines have higher numbers. GT.M does not include the RECALL command in the listing. If the RECALL command is issued from a location other than the Direct Mode prompt, GT.M issues a run-time error.


GTM>write $zgbldir 
GTM>set $zgbldir="test.gld"

GTM>set a=10

GTM>set b=a


1 set b=a
2 set a=10
3 set $zgbldir="test.gld"
4 write $zgbldir


This REC[ALL] command displays the previously entered commands.

You can also display a selected command by entering RECALL and the line number of the command you want to retrieve.


GTM>recall 2
GTM>set a=10

This RECALLs the line number two (2).

If the RE[CALL] command includes a text parameter, GT.M displays the most recent command matching the text after the RE[CALL] command.


GTM>recall write
GTM>write $zgbldir

This RECALLs "WRITE", the command most recently beginning with this text. Note that the RECALL command text is case sensitive. The RECALL command with a text argument treats WRITE and write differently, that is, it treats them case sensitively. If you first type the WRITE command in lower-case and then type WRITE in upper-case to recall it, the RECALL command does not find a match.

Line Editing

GT.M permits the use of the GT.M command line editor at the Direct Mode prompt and during M READs from a terminal. The GT.M line editor allows cursor positioning using the <CTRL> key, edit keypad and function keys.

The GT.M Direct Mode line editing keys are as follows:

Backspace: Deletes the character to the left of the cursor

Delete: Deletes the character to the left of the cursor

Up-arrow: Moves to a less recent item in the RECALL list

Down-arrow: Moves to a more recent item in the RECALL list

Left-arrow: Moves the cursor one character to the left

Right-arrow: Moves the cursor one character to the right

<CTRL-A>: Moves the cursor to the beginning of the line

<CTRL-B>: Moves the cursor one character towards the beginning of the line

<CTRL-D>: On an empty line, terminates GT.M and returns control to the shell.

<CTRL-E>: Moves the cursor to the end of the line

<CTRL-F>: Moves the cursor one character towards the end of the line

<CTRL-K>: Deletes all characters from the cursor to the end of the line

<CTRL-U>: Deletes the entire line

[Note] Note

When entering commands at the direct mode prompt, the insert mode can be toggled for that line by using the insert key. When GT.M starts, insert mode is enabled unless the value of the gtm_principal_editing environment variable includes the string NOINSERT. If insert mode is disabled or enabled for the $PRINCIPAL device by an USE statement before returning to direct mode, it will remain disabled or enabled at direct mode. The insert mode can be toggled within a direct mode line using the terminal’s INSERT key.

The M Invocation Stack

The ANSI M Standard describes certain M operations in terms of how a stack-based virtual machine would operate. A stack is a repository for tracking temporary information on a "last-in/first-out" (LIFO) basis. M program behavior can be understood using a stack-based model. However, the standard is not explicit in defining how an implementation must maintain a stack or even whether it must use one at all.

The stack model provides a trail of routines currently in progress that shows the location of all the M operations that performed the invocations leading to the current point.

The ZSHOW command makes this stack information available within GT.M. For more information, see “Using the Invocation Stack in Debugging” in this chapter, and the command description at “ZSHow”.

Exiting Direct Mode

Five M commands can terminate a Direct Mode session:

  • HALT



  • GOTO


The HALT command exits Direct Mode and terminates the M process.

The ZHALT command exits Direct Mode and returns the exit status to the calling environment.

The ZCONTINUE command instructs GT.M to exit Direct Mode and resume routine execution at the current point in the M invocation stack. This may be the point where GT.M interrupted execution and entered Direct Mode. However, when the Direct Mode interaction includes a QUIT command, it modifies the invocation stack and causes ZCONTINUE to resume execution at another point.

The GOTO and ZGOTO commands instruct GT.M to leave Direct Mode, and transfer control to a specified entry reference.