Labeling Output with Tags
To label a result with a tag:
1.Put the output object on the stack.
2.Enter a tag — a string, a quoted name, or a number.
3.Enter the →TAG command (PRG TYPE menu).
«… object tag →TAG … »
→TAG takes two arguments — an object and a tag — from the stack and return a tagged object.
Example: The following program TTAG is identical to TINPUT, except that it returns the result as AREA: value.
Program: | Comments: | |
|
| |
« |
| |
"Key in a, b" |
| |
{ ":a::b:" {1 0} V } |
| |
INPUT OBJ→ |
| |
TORSA |
| |
"AREA" | Enters the tag (a string). | |
→TAG | Uses the program result | |
| and string to create the | |
| tagged object. | |
» |
| |
|
| |
`OTTAG ‰ | Stores the program in | |
TTAG. | ||
| ||
|
|
Execute TTAG to calculate the area of a torus of inner radius a = 1.5 and outer radius b = 1.85. The answer is returned as a tagged object.
J%TTAG%1.5 ˜1.85 `
Labeling and Displaying Output as Strings
To label and display a result as a string:
1.Put the output object on the stack.
2.Enter the →STR command (PRG TYPE menu).
3.Enter a string to label the object (with "" delimiters).
4.Enter the SWAP + commands to swap and concatenate the strings.
5.Enter a number specifying the line to display the string on.
6.Enter the DISP command (PRG OUT menu).
«… object →STR label SWAP + line DISP … »
DISP displays a string without its "" delimiters.