Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

WRITE

M[UMPS] by Example

Introduced in the 1977 ANSI M[UMPS] language standard.

Write # ; Start at a new page
Write "This appears at the top of the page."
Write !!!!!
Write "Now we are 5 lines further down."
Write ?10,"And this line is indented (10 positions)."

The most common usages of the Write command.

Write 3+4,A_B,!
Write !,$JUSTIFY(X,9)

Expressions are allowed in arguments of the Write command.

Note: The exclamation mark may appear anywhere in a sequence of arguments of the Write command. Choose one standard for your application (always at the beginning, or always the end) and stick to that. Which one you choose is not important; being consistent is.

Write *65
Although most implementations will interprete this command as Write $Char(65), the effect of this command is implementation-specific and device specific. In general, this syntax is not considered to be portable.

Addition in the 1995 ANSI M[UMPS] language standard.

Use DEVICE::"X3.64" Write /CUP(5,10)
Position the cursor at location (5,10) and update $X and $Y accordingly ($X=5, $Y=10).

Use DEVICE::"X3.64" Write /SGR(0),"Reset"
Use DEVICE::"X3.64" Write /SGR(1),"Bold"
Use DEVICE::"X3.64" Write /SGR(2),"Faint"
Use DEVICE::"X3.64" Write /SGR(3),"Italic"
Use DEVICE::"X3.64" Write /SGR(4),"Underscore"
Use DEVICE::"X3.64" Write /SGR(5),"Slow blink"
Use DEVICE::"X3.64" Write /SGR(6),"Rapid blink"
Use DEVICE::"X3.64" Write /SGR(7),"Reverse video"

Turn on the various graphic renditions. Of course, not all devices can realize all attributes (it would be a neat trick to implement blinking on a laserprinter...), but these are the rendition codes that are defined in ANSI X3.64.

Sample function to erase a display:
Open TTY Use TTY::"X3.64"
Use $Principal Write !,"Cursor to left upper corner."
Use TTY Write /CUP(1,1)
Use $Principal Write !,"Erase screen."
Use TTY Write /ED

Create a display with questions in bold-face and answers in reverse video:
Write /CUP(1,1) Write /ED
For I=1:1:QUESTIONS Do
. Write /CUP(YQ(I),XQ(I))
. Write /SGR(1),QUESTION(I)
. Write /CUP(YA(I),XA(I))
. Write /SGR(7),ANSWER(I)
. Quit

The most common functions in ANSI X3.64 are itemized in the X3.64 description.

Approved for addition in a future M[UMPS] language standard.

The ability to specify an "output time-out" is added. An output time-out is specified as a device parameter in an OPEN or USE command. Examples are shown with the Use command.

The addition of a binding to TCP/IP socket devices includes a number of new controlmnemonics.

Use DEVICE::"SOCKET" Write /LISTEN
Switch to the mnemonicspace that handles TCP/IP connections (sockets), and establish the implementation-default queue depth for listening to incoming requests.

Write /LISTEN(depth)
Switch to the mnemonicspace that handles TCP/IP connections (sockets), and use the specified value for the queue depth for listening to incoming requests.

Write /WAIT
Wait for an event to occur on any socket associated with the current device. When an event occurs, the value of special variable $Key will indicate the nature of the event.

Write /WAIT(duration)
Wait for an event to occur on any socket associated with the current device, or until the time-out specified in the parameter elapses (whichever occurs first). When an event occurs, the value of special variable $Key will indicate the nature of the event.

Whether or not a duration is specified, the value of $Key will contain the substring "CONNECT" when a connection request is received by a "listening" server, and the value of $Key will contain the substring "READ" when a message is received through a connectionless protocol.

More examples are shown with the Use command.

Approved for addition in a future M[UMPS] Language standard.

User-definable I/O handling has been added. When user-definable I/O handling is active:

Examples with naked references:

Write VALUE
Set ^ABC(1,2)="reset naked indicator"
; naked indicator is now ^ABC(1,
Write ^(3,4)

; naked indicator is now: ^ABC(1,3,
; Actual reference is: ^ABC(1,3,4)

Addition in the 1994 ANSI M[UMPS] GKS Binding.

STAR(DEVICE,DISPLAY) ;
 New BLUE,YELLOW,GREEN,A,B,C,WK1
 ;
 ; This routine draws a yellow star on a blue
 ; background and writes the title ‘STAR’ in
 ; green under the star.
 ;
 ; GKS level: ma
 ; The implementation must support at least one
 ; workstation of category output or outin.
 ;
 Open DEVICE,DISPLAY ; Implementation dependent
 Use DEVICE::"GKS"
 Set WK1="Workstation one"
 ; OPEN virtual GKS display
 Write /GOPGS(DISPLAY,32)
 Write /GOPWK(WK1,64,1)
 Write /ACWK(WK1)
 ; Center the window and the origin
 Write /GSWN(1,"(–1.25,1.25,–1.25,1.25)")
 Write /GSELNT(1)
 ; Define the colours to be used
 Set BLUE="0,0,1"
 Set YELLOW="1,1,0"
 Set GREEN="0,1,0"
 Write /GSCR(WK1,0,BLUE)
 Write /GSCR(WK1,1,YELLOW)
 Write /GSCR(WK1,2,GREEN)
 ; Draw the star
 Set A="INDIVIDUAL",B="BUNDLED"
 Write /GSASF(B,B,B,B,B,B,B,B,B,B,A,B,A)
 Write /GSFAIS("SOLID"),/GSFACI(1)
 Set A=0.951057,B=0.309017,C=0.58775
 Write /GFA(+A,+B,-A,+B,+C,-A,0,1,-C,+A)
 ; Title of graph
 Write /GSCHH(0.15)
 Write /GSTXAL("CENTRE","HALF")
 Write /GSTXCI(2)
 Write /GTX((0,1.1),"STAR")
 ; Close the graph and the virtual display
 Write /GDAWK(WK1)
 Write /GCLWK(WK1)
 Write /GCLKS
 Close DEVICE,DISLAY
 Quit

Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 15-Nov-2023, 18:57:54.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)