Object Icon inherits a textual preprocessor from Icon. The following directives are recognised.
$line n [[filename] encoding]Set the line number and optionally filename and encoding. These values are passed to the lexical analyzer (by way of a special comment in the output).
$include filenameInclude the given file.
$load identifier filenameLoad the contents of the given file as a string literal, and set those contents as the value of the given macro variable. For example, if a particular text file contained the single line “testing 1 2 3”, and a newline, then
$load STR "file.txt"
would be equivalent to
$define STR "testing 1 2 3\n"
This directive is particularly useful for compiling image files, such as PNG icons, into the object file.
$uload identifier filenameThis is like $load, except that the resulting string is a ucs literal. The contents of the file must therefore be in UTF-8 format.
$define identifier textSet the given variable to a value.
$undef identifierClear the given variable.
$if expressionInclude or exclude a block of text based on the given boolean expression. The expression may be a combination of the following symbols :-
x & y, for logical and.x | y, for logical or.~ x, for logical not.(x), for grouping.The usual operator precedence applies - & has higher precedence than |.
For example :-
$if _LINUX | _DARWIN
...
$elsif expressionFollowing a $if or $elsif, this can be used to provide a further conditional expression and associated block.
$elseFollowing a $if or $elsif, this can be used to include a block of text if the condition was false.
$endifThis ends a conditional statement block.
$encoding nameSet the encoding of the file. This is passed to the lexical analyzer (by way of a special comment in the output). Allowed values of name are :-
ASCII (the default)ISO-8859-1UTF-8$error [text]Signal an explicit error message.
Contents