Introduced in the 1977 ANSI M[UMPS] language standard.
This function returns the text of a line of M[UMPS] code.
Assume that the following program is stored:
PGM ;Author;Comment SET WHERE=$TEXT(+0) 1 SET Y=3 WRITE Y READ X LAB1 WRITE !,X
$TEXT(PGM)="PGM ; Author;Comment"
$TEXT(LAB1)="LAB1 WRITE !,X"
$TEXT(PGM+1)="1 SET Y=3 WRITE Y"
$TEXT(+1)="PGM ; Author;Comment"
$TEXT(LAB1+1)=""
$TEXT(1+1)=" READ X"
SET B=3
$TEXT(+B)=" READ X"
If this program is executed, the value of WHERE, in the second line of the program, will become equal to the name of the routine ("PGM").
The following line of code will print a program:
FOR I=1:1 SET X=$TEXT(+I)
QUIT:X="" WRITE X,!
Notes:
A line in a program looks like:
Optional: label with optional parameter list
Mandatory: line start character (space)
Optional: commands
Optional comment
This means that:
Many groups of programmers use conventions to make the content of the first line of a routine be according to a specific format, so that these "first lines" can be used for internal reports.
 Write !,"Routine",?12,"Author(s)",!
Set R="" For Set R=$Order(^$Routine(R)) Quit:R="" Do
. Set x=$Text(+1^@R) Write !,R,?12,$Piece(X,";",2)
Note: Many of such conventions exist, and most can be supported by code written in ANSI standard M[UMPS]. The standard, however, does not endorse any specific format convention for the first line of a routine.
Assume that the the source code of a section of a routine looks like:
... FOR I=1:1 SET X=$TEXT(HDR+I) QUIT:X=" --" WRITE !,X ... HDR ; End Of Year Report Section XXX -- ...
The three lines that follow the label HDR do not conform to the syntax of a M[UMPS] routine, and may cause problems when loading the source code as a routine into a M[UMPS] environemnt.
Although this particular usage appears to have been quite popular at one time, there never was a language standard that supported such usage.
Methods of performing the intended task that do conform to the ANSI language standard would be:
... FOR I=1:1 SET X=$TEXT(HDR+I) QUIT:X=" --" DO . WRITE !,$EXTRACT(X,3,$LENGTH(X)) ... HDR ; ;End Of Year Report ;Section XXX ;-- ...
Or simply:
... DO HDR ... HDR ; WRITE!,"End Of Year Report" WRITE!,"Section XXX" QUIT ...
Addition in the 1984 ANSI M[UMPS] language standard.
A special meaning is given to the reference $TEXT(+0). This reference will return the name of the currently executing routine.
Modification in the 1990 M[UMPS] language standard.
The 1984 language standard contained imprecise wording that indicated that the spaces for a line-start should be compressed in the function value and be represented as one single space. This wording was changed to reflect the original intent, which is to represent a line "as it is in the source code".
Addition in the 1995 ANSI M[UMPS] language standard.
The following line of code will print a program:
FOR I=1:1 SET X=$TEXT(+I^ROUT)
QUIT:X="" WRITE X,!
Note: a reference like +OFFSET^ROUTINE is acceptable as a parameter for $TEXT, but not as an argument for the commands DO and GOTO.
Approved for addition in a future ANSI M[UMPS] language standard.Trailing spaces are allowed at the end of a line.
This means that it would be valid to create a routine containing commands like (in subroutine A the character ¤ has been used to make all space characters visible):
XECUTE $TEXT(A+1)_$TEXT(A+5)
...
QUIT
A¤;
¤SET¤START=1¤¤
¤DO¤VALIDATE1¤¤
¤DO¤VALIDATE2¤¤
¤DO¤QUERY7¤¤
¤DO¤RESET9¤¤
¤DO¤VALIDATE11¤¤
¤;;¤--¤end
and the code that would be XECUTEd would be:
¤SET¤START=1¤¤¤DO¤RESET9¤¤
Examples with naked references:
$TEXT(LINEREF)
SET ^ABC(1,2)="reset naked indicator"
; Naked indicator is now ^ABC(1,
SET ^(3,4)=$TEXT(@^(5,6))
; 1. fetch ^(5,6) = ^ABC(1,5,6)
; 2. store ^(3,4) = ^ABC(1,5,3,4)
; Naked indicator is now: ^ABC(1,5,3,
This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under
the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.