next up previous
Next: 7. System Parameter Access with Up: A Tutorial on the Previous: 5. Text Manipulations

6. Controlling the Output with the Register O

 

The output control register o is a bit mapped register, which is used to control the various aspects of the dialog output during the execution of a macro. The following table lists the function associated with each bit:

Output Control Register O
bit:value:description:
01Suppress standard dialog output. If bit 0 is ON, the standard dialog output generated by EMME/2 is not displayed on the screen. Instead, this output is directed to a scratch file, which is automatically erased at the end of each module. Thus, activating this bit will ``silence'' the macro, so that only output which is generated explicitly by the macro via macro comments will be displayed on the screen. If bit 0 is OFF (default), all dialog output is directed to the screen.
12Suppress comment prefix. If bit 1 is OFF (default), macro comments will be echoed at the screen including the ~/ command prefix, so that the comment is clearly identifyable as a macro comment. If bit 1 is ON, the leading ~/ characters are stripped before echoing and only the comment itself is displayed on the screen.
24Suppress echo of macro input. If bit 2 is OFF (default), the answers generated by the macro are displayed on the screen (preceded by the character ``<''). In addition, if switch 15, ``dialog/macro debug mode'', is ON, all macro commands are echoed as well on the screen. If bit 2 is ON, the output of the answers generated by the macro, as well as the macro commands, are not echoed on the screen as they are executed.
38Macro single step tracing mode. If this bit is ON, the macro single stepping mode is activated. This mode can be used for macro debugging, as described in section 9.
416Fall back to single step tracing mode. If this bit is set and a fatal error condition occurs, the macro processing is not terminated (as is done by default), but the single step mode is entered, so that the user can analyze the problem and, if necessary, take corrective action. See section 9 for further information.
532Suppress programmed pauses. After certain operations, EMME/2 waits for a few seconds, in order to give the user some time to read a displayed message (e.g. after a report has been sent to the print file). When running a macro, these pauses are not always needed -- sometimes they will even significantly slow down the execution of a macro. Activating bit 5 will suppress any such programmed pauses that normally happen during module execution.
664Read an extra input line at programmed pauses (regardless of the setting of bit 5) and just before leaving a module. While the contents of the input line itself is ignored, the important aspect here is that it allows macro commands to be executed at this point. At pauses (which are usually followed by an erase of the screen), a macro may implement a user prompt to avoid that the information on the screen disappears before the user has taken note of it. At the end of a module, a macro may use this extra input line to do clean-up or post processing work before module specific information (such as the content of the gN registers) is lost. For these special input lines, the register q assumes the value -1.
All following bits are automatically reset after the corresponding function has been performed.
8256Erase screen. When this bit is set, the screen is erased and the cursor is positioned at the top left corner of the screen.
9512Rewind scratch file. If this bit is set, the scratch file used to store the dialog output of the current module is rewound. This function is only useful if bit 0 was set (or still is) during the call to the current module.
101024Backspace scratch file. When this bit is set, the scratch file used to store the dialog output of the current module is backspaced by one record. This function is only useful if bit 0 was set (or still is) during the call to the current module.
112048Read record from scratch file into register t9. When this bit is set, the next record from the scratch file is read and stored into the text register t9. From there it can be accessed by the macro in the usual manner. This function is only useful if bit 0 was set (or still is) during the call to the current module.
124096Close and discard current scratch file. If this bit is set, the current scratch file is closed and deleted. If bit 0 is still ON, a new scratch file will be opened automatically as soon as the next dialog output is generated. Activating this bit might be needed in macros which generate a great quantity of dialog output in a single module (loops!), in order to avoid disk space problems.
In order to set up a macro to be ``quiet'', i.e. not to display the dialog that the macro generates while running, the o register is usually set to the value 7 (=1+2+4). This corresponds to setting the bits 0, 1 and 2 to ON, implying that neither dialog output nor input is displayed and that macro comments are echoed without the leading ``~/''.

Since it becomes difficult to debug a macro once the dialog is hidden this way, it is recommended to test switch 15 before setting the o register. This way, if ever needed, the macro can be made ``noisy'' by simply issuing the command on=15 at the main menu, without any need to edit the macro. This could be done by inserting the following sequence at the beginning of a macro:

    ~?!i&32768     / if switch 15 (dialog/macro echo mode) is OFF 
    ~o=7           / set o-register to hide all dialog
If the macro should start with a screen erase (similar to an EMME/2 module), it suffices to set bit 8 of the o register. In the above example this could be done by replacing the value 7 by 263 (=7+256). If the screen is to be erased at some place within the macro, this can be done with the bitwise OR command ``~o|256'', which does not affect the setting of any other bits.

The bits 9-12 allow a macro to access the dialog that was sent to the scratch file instead of the screen. This way, a macro get the possibility to interpret context dependent information that is not available in any register, but appears somewhere in the dialog output.



Exercise 6.1:
Write a macro which exports all predefined windows into an external file, which then can be used as a macro in another data bank to reinstall the same set of predefined windows.


next up previous
Next: 7. System Parameter Access with Up: A Tutorial on the Previous: 5. Text Manipulations

Heinz Spiess, EMME/2 Support Center
Fri Sep 27 13:04:28 MET DST 1996