April 27, 1981 CMS MACROS FOR TERMINAL COMMUNICATIONS There are four CMS macros you can use to write interactive,
terminal-oriented programs. They are RDTERM, WRTERM, LINEDIT, and PAITT. RDTERM and WRTERM only require a read/write buffer for sending and rece1v1ng lines from the terminal. The third, LINEDIT, has a
substitution and translation capability. When you use the WRTERM macro to write a line to your terminal you
can specify the actual text line in the macro instruction, for example: DISPLAY WRTERM 'GOOD MORNING' You can al30 specify the message text by referri.ng to a buffer that
contains the message.
The RDTERM macro accepts a line from the terminal and reads it into a
buffer you specify. You could use the RDTERM and WRTERM macros together,
as follows: WRITE READ REWRITE BUFFER WRTERM 'ENTER LINE'
RDTERM BUFFER LR 3,0 WRTERM BUFFER, (3)
DS CL130 In this example, the WRTERM macro results in a prompting message. Then
the RDTERM macro accepts a line from the terminal and places it in the
buffer BUFFER. The length of the line read, contained in register 0 on
return from the RDTERM macro, is saved in register 3. When you specify
a buffer address on the WRTERM macro instruction, you must specify the
length of the line to be written. Here, register notation is used to
indicate that the length is contained in register 3.
The LINEDIT macro converts decimal and hexadecimal data into EBCDIC, and places the converted value into a specified field in an output line.
There are list and execute forms of the macro instruction, which you can
use in writing reentrant code. Another option allows you to write lines
to the offline printer. The LINEDIT macro is described, with examples,
in CMS AnS Macro Reference. Figure 21 shows how you
miqht use the LINEDIT macro to convert and display CMS return codes.
The WAITT (wait terminal) macro instruction can help you to
synchronize input and output to the terminal. If you are executing a
program that reads and writes to the·terminal frequently, you may want
to issue a WAITT macro instruction to halt execution of the program
until all terminal I/O has completed. CMS MACROS FOR UNIT RECORD AND TAPE I/O CMS provides macros to simplify reading and punching cards (RDCARD and PUNCHC), and creating printer files (PRINTL). When you use either the PUNCHC or PRINTL macros to write or punch output files while a program
is executing, you should remember to issue a CLOSE command for your
virtual printer or punch when you are finished. You can do this either
after your proqram returns control to CMS, by entering: 250 IBM VM/370 CMS User's Guide
cp close e
-- or --
cp close d or
6
you can set up a parameter list with the command line CP CLOSE E or CP CLOSE D and issue an SVC 202.
The tape control macros, RDTAPE, WRTAPE and TAPECTL, can read and
write CMS files from tape, or control the positioning of a tape. INTERRUPTION HANDLING MACROS You can set up routines in your programs to handle interruptions caused
by I/O devices, by SVCs, or by external interruptions using the HNDINT, HNDSVC, or HNDEIT macro instructions.
with the HNDINT macro instruction, you can specify addresses that are
to receive control when an interruption occurs for a specified device.
If the WAIT option is used for a device specified in the HNDINT macro
instruction, then the interruption handling routine specified for the
device does not receive control until after the WAITD macro instruction
is issued for the device. You can use the HNDSVC macro instruction to trap supervisor call
instructions of particular numbers, if, for example, you want to perform
some additional function before passing control or you do not want any SVCs of the specified number to be executed.
The CP EXTERNAL command simulates external interruptions in your
virtual machine; if you want to be able to pass control to a particular
internal routine in the event of an external interruption, you can use
the HNDEXT macro instruction.
Updating Source Programs Using eMS As you test and modify programs, you may to keep backup copies of
the source programs. Then you can always return to a certain level of a in case you have an error. CMS provides several approaches to
the problem of program backup: the method you choose depends on the
complexity of your project, the changes you want to make, and the size
of your programs.
The simplest method is to make a copy of the current source file
under a new name. You can do this using either the COPYFILE command or
the eMS editor. If you use the COpy FILE command, your command line
might be:
copy file account assemble a oldacct assemble a
Then, you can use the editor to modify ACCOUNT ASSEMBLE; the file OLDACCT ASSEMBLE contains your original source file. You can make a copy of your source file using the eMS editor
directly. For example, if you issue:
edit account assemble
EDIT:
fname newacct
Section 13. Programming for the CMS Environment 251
Previous Page Next Page