Next: Debugging with macros, Previous: Tokens, Up: FWEB macros [Contents][Index]
Built-in functions behave in most ways like macros. In some cases they actually are macros, but other times they implement functions that a user could not define. They all begin with a dollar sign and are in upper case.
In using these built-ins, confusion may arise regarding the order of
expansion of various arguments. When they are implemented as macros,
they are subject to the same ANSI-C preprocessor rules as other
FWEB macros, which is that all arguments are fully expanded before
generating the replacement text of the macro. When they are directly
implemented as a primitive function, however, that rule may not apply.
For example, $IF
expands only its first argument during its first
pass of processing; depending on the results of that expansion, it then
expands either its second or third argument, but not both.
The built-in function $DUMPDEF
can be used to understand and
debug the action of the built-in functions. See $DUMPDEF.
In the original FWEB design, built-in functions began with an underscore. This usage conflicts with the conventions for reserved words in ANSI C, and has been eliminated. All FWEB built-ins now begin with a dollar sign.
No user-defined macro should begin with a dollar sign! It might interfere with the functioning of some internal built-in function.
GENERAL INFORMATION ABOUT BUILT-IN FUNCTION DESIGN | ||
---|---|---|
• Strings and quotes | Quoted and non-quoted strings. | |
• Protection | By default, built-in functions may not be redefined. | |
INDIVIDUAL BUILT-IN FUNCTIONS | ||
• $A | Convert to ASCII. | |
• $ABS | Absolute value. | |
• $ASSERT | Assert a condition. | |
• $AUTHOR | RCS global keyword; see $KEYWORD. | |
• $COMMENT | Generate a comment. | |
• $DATE | Today’s date. | |
• $DATE_TIME | RCS global keyword; see $KEYWORD. | |
• $DAY | Today. | |
• $DECR | Decrement a macro. | |
• $DEFINE | Define a (deferred) macro. | |
• $DO | Macro DO loop. | |
• $DUMPDEF | Dump macro definitions to the terminal. | |
• $E | Base of the natural logarithms: 2.71828... | |
• $ERROR | Send error message to output. | |
• $EVAL | Evaluate an expression. | |
• $EXP | Exponential function. | |
• $GETENV | Get value of environment variable. | |
• $HEADER | RCS global keyword; see $KEYWORD. | |
• $HOME | The user’s home directory. | |
• $ID | RCS global keyword; see $KEYWORD. | |
• $IF | Two-way conditional: “If expression is true” | |
• $IFCASE | n-way conditional. | |
• $IFDEF | Two-way conditional: “If macro is defined” | |
• $IFNDEF | Two-way conditional: “If macro is not defined” | |
• $IFELSE | Two-way conditional: “If macro1 equals macro2” | |
• $INCR | Increment a macro. | |
• $INPUT_LINE | Line number that begins current section. | |
• $KEYWORD | Extract text of global RCS-like keyword. | |
• $L | Change string to lower case. | |
• $L_KEYWORD | Extract text of local RCS-like keyword. | |
• $LANGUAGE | Identifier for current language. | |
• $LANGUAGE_NUM | Number of current language. | |
• $LEN | Length of string. | |
• $LOCKER | RCS global keyword; see $KEYWORD. | |
• $LOG | Natural logarithm. | |
• $LOG10 | Logarithm to the base 10. | |
• $M | Define a (deferred) macro. | |
• $MAX | Maximum of one or more elements. | |
• $MIN | Minimum of one or more elements. | |
• $MODULE_NAME | Name of present web module.
| |
• $MODULES | Total number of independent modules. | |
• $NAME | RCS global keyword; see $KEYWORD. | |
• $OUTPUT_LINE | Current line number of tangled output. | |
• $P | The C preprocessor symbol # (an unquoted string).
| |
• $PI | 3.14159... | |
• $POW | Raise to a power. | |
• $PP | The C preprocessor symbol # (a character).
| |
• $RCSFILE | RCS global keyword; see $KEYWORD. | |
• $REVISION | RCS global keyword; see $KEYWORD. | |
• $ROUTINE | Current Ratfor program, function, or subroutine. | |
• $SECTION_NUM | Number of current section. | |
• $SECTIONS | Maximum number of sections. | |
• $SOURCE | RCS global keyword; see $KEYWORD. | |
• $SQRT | Square root. | |
• $STATE | RCS global keyword; see $KEYWORD. | |
• $STRING | Expand argument, then stringize. | |
• $STUB | ||
• $TIME | The local time. | |
• $TRANSLIT | Transliterate a string. | |
• $U | Change string to upper case. | |
• $UNDEF | Undefine an FWEB macro. | |
• $UNQUOTE | Remove quotes from string (leaving an unquoted string). | |
• $UNSTRING | Remove quotes and string delimiters from string. | |
• $VERBATIM | (Obsolete.) | |
• $VERSION | FWEB version number. |
Next: Debugging with macros, Previous: Tokens, Up: FWEB macros [Contents][Index]