TPARM function
Syntax
TPARM (terminfo.string, [arg1], [arg2], [arg3], [arg4], [arg5],
[arg6], [arg7], [arg8] )
Description
Use the TPARM function to evaluate a parameterized terminfo string.
terminfo.string represents a string of characters to be compiled by the terminfo compiler, tic. These terminal descriptions define the sequences of characters to send to the terminal to perform special functions. terminfo.string evaluates to one of four types of capability: numeric, Boolean, string, or parameterized string. If terminfo.string or any of the eight arguments evaluates to the null value, the TPARM function fails and the program terminates with a run-time error message.
Numeric capabilities are limited to a length of five characters that must form a valid number. Only nonnegative numbers 0 through 32,767 are allowed. If a value for a particular capability does not apply, the field should be left blank.
Boolean capabilities are limited to a length of one character. The letter Y (in either uppercase or lowercase) indicates that the specified capability is present. Any value other than Y indicates that the specified capability is not present.
String capabilities are limited to a length of 44 characters. You can enter special characters as follows:
- \E or \e
- The ESC character (ASCII 27).
- \n or \l
- The LINEFEED character (ASCII 10).
- \r
- The RETURN character (ASCII 13).
- \t
- The TAB character (ASCII 9).
- \b
- The BACKSPACE character (ASCII 8).
- \f
- The formfeed character (ASCII 12).
- \s
- A space (ASCII 32).
- ^x
- The representation for a control character (ASCII 0 through 31). The character can be either uppercase or lowercase. A list of some control character representations follows:
- Representation
- Control Character
- ^A
- ^a
- ASCII 1 (Ctrl-A)
- ASCII 1 (Ctrl-A)
- ^@
- ASCII 0
- ^[
- ASCII 27 (Esc)
- ^\
- ASCII 28
- ^]
- ASCII 29
- ^^
- ASCII 30
- ^_
- ASCII 31
- ^?
- ASCII 127 (Del)
- \nnn
- Represents the ASCII character with a value of nnn in octal-for example \033 is the Esc character (ASCII 27).
- \\
- Represents the "\" character.
- \,
- Represents the "," character.
- \^
- Represents the "^" character.
Parameterized string capabilities, such as cursor addressing, use special encoding to include values in the appropriate format. The parameter mechanism is a stack with several commands to manipulate it:
| Code | Explanation |
|---|---|
| %pn | Push parameter number n onto the stack. Parameters number 1 through 8 are allowed and are represented by arg1 through arg8 of the TPARM function. |
| %'c' | The ASCII value of character c is pushed onto the stack. |
| %[nnn] | Decimal number nnn is pushed onto the top of the stack. |
| %d | Pop the top parameter off the stack, and output it as a decimal number. |
| %nd | Pop the top parameter off the stack, and output it as a decimal number in a field n characters wide. |
| %0nd | Like %nd, except that 0s are used to fill out the field. |
| %c | The top of the stack is taken as a single ASCII character and output. |
| %s | The top of the stack is taken as a string and output. |
| %+ %- %* %/ |
The top two elements are popped off the stack and added, subtracted, multiplied, or divided. The result is pushed back on the stack. The fractional portion of a quotient is discarded. |
| %m | The second element on the stack is taken modulo of the first element, and the result is pushed onto the stack. |
| %& % | %^ | The top two elements are popped off the stack and a bitwise AND, OR, or XOR operation is performed. The result is pushed onto the stack. |
| %= %< %> | The second element on the stack is tested for being equal to, less then, or greater than the first element. If the comparison is true, a 1 is pushed onto the stack, otherwise a 0 is pushed. |
| %! %~ | The stack is popped, and either the logical or the bitwise NOT of the first element is pushed onto the stack. |
| %i | One (1) is added to the first two parameters. This is useful for terminals that use a one-based cursor address, rather than a zero-based. |
| %Px | Pop the stack, and put the result into variable x, where x is a lowercase letter (a - z). |
| %gx | Push the value of variable x on the top of the stack. |
%? exp %t exp [%e exp] %; |
Form an if-then-else expression, with "%?" representing "IF", "%t"
representing "THEN", "%e" representing "ELSE", and "%;" terminating the expression.
The else expression is optional. Else-If expressions are possible. For example:
Cn are conditions, and Bn are bodies. |
| %% | Output a percent sign (%). |
A delay in milliseconds can appear anywhere in a string capability. A delay is specified by $<nnn>, where nnn is a decimal number indicating the number of milliseconds (one thousandth of a second) of delay desired. A proper number of delay characters will be output, depending on the current baud rate.