Table of Contents
|
Control codes in the format function's control-string must start with a tilde [~] character. Each code ends with one of the codes listed below. Some codes may have parameters, if more than one parameter these will be separated by commas [,]. The following lists the various codes and their meanings:
Basic output
~C (Tilde C: Character)
The next argument should be a character. In case of AutoLisp there's no character type (yet), so in this case the first character of an input string will be used.
~% (Tilde Percentile: New Line)
A new line is output in this position. There's an optional parameter to this where ~N% outputs $N \times NewLines$. So a code of ~3% would result in 3 new lines being placed in this position.
~& (Tilde Ampersand: Fresh Line)
Inserts a new line at this position if and only if it's not already at the start of a line. There's an optional parameter to this where ~N& outputs $N \times NewLines$ if the position is not at the start of a line, else it outputs $( N - 1 ) \times NewLines$. So a code of ~3& would result in 3 new lines being placed in this position if the position is not at the start of a line, else it would place 2 new lines.
~| (Tilde Vertical-bar: Page Break / Form Feed)
Outputs a page separator character - Form Feed (Unicode "\U+000C" ; or ASCII 12). In AutoLisp it would be the ASCII version using the Octal code of "\014". There's an optional parameter to this where ~N| outputs $N \times FormFeeds$. So a code of ~3| would result in 3 form feed characters being placed in this position.
~~ (Tilde Tilde: Tilde)
Can be seen as the "escape" code. It simply results in a tilde character being output to the position. ~N~ would result in $N \times Tildes$, so ~3~ becomes "~~~".
Integer Controls
~R (Tilde R: Radix Control)
Converts the integer argument into a value displayed in a specified radix. There are 4 optional parameters to this control, "~radix,mincol,padchar,commachar,comma-intervalR":
- radix: A base 10 integer showing the radix. If omitted it defaults to cardinal English, such that "~R" with an value of 4 would display as "four". Special cases using modifiers:
- "~:R" results in an ordinal English number, e.g. "fourth".
- "~@R" results in Roman Numerals, e.g. "VI".
- "~:@R" results in old Roman Numerals, e.g. "IIII".
- mincol: The minimum length of the output, also known as field-length. Default is 0. E.g. "~10,5R" with a value of 123 would result in "00123".
- padchar: Has no meaning if mincol is omitted, or less than / equal to the length of the output. The character used in padding, defaults to 0. E.g. "~10,5,` R" with a value of 123 would result in " 123".
- commachar: Has no meaning without an accompanying comma-interval. Defaults to a comma [,], so "~10, , , ,3R" with a value of 12345 would result in "12,345".
- comma-interval: A base 10 integer showing the interval between comma separators. Default is 0. E.g. "~10, , ,` ,3R" with a value of 12345 would result in "12 345".
~D (Tilde D: Decimal)
This is generally the same as using the Radix code with a radix of 10: "~10R" is equivalent to "~D". It only has 4 optional parameters, the mincol,padchar,commachar,comma-interval. These work the same as for the Radix code. If the value of the argument is not of an integer type the result is the same as would be gotten from "~A" with a decimal base.
~B (Tilde B: Binary)
This is generally the same as using the Radix code with a radix of 2: "~2R" is equivalent to "~B". It only has 4 optional parameters, the mincol,padchar,commachar,comma-interval. These work the same as for the Radix code. If the value of the argument is not of an integer type the result is the same as would be gotten from "~A" with a decimal base.
~O (Tilde O: Octal)
This is generally the same as using the Radix code with a radix of 8: "~8R" is equivalent to "~O". It only has 4 optional parameters, the mincol,padchar,commachar,comma-interval. These work the same as for the Radix code. If the value of the argument is not of an integer type the result is the same as would be gotten from "~A" with a decimal base.
~X (Tilde X: Hexadecimal)
This is generally the same as using the Radix code with a radix of 16: "~16R" is equivalent to "~X". It only has 4 optional parameters, the mincol,padchar,commachar,comma-interval. These work the same as for the Radix code. If the value of the argument is not of an integer type the result is the same as would be gotten from "~A" with a decimal base.