Contents | Parent Topic | Previous Topic | Next Topic
Home | Catalog
A variable is a named value. Document-wide settings are controlled in SDF using variables. Likewise, authors can define and access their own variables. In either case, the value of a variable can be referenced in a paragraph by delimiting it with the special symbols [[ and ]].
For example:
!define MY_EMAIL 'abc@xyz.com' My electronic mail address is [[MY_EMAIL]].
The result is:
My electronic mail address is abc@xyz.com.
Some commonly used system variables are:
Variable | Description |
Options: | |
OPT_LOOK | the overall look (e.g. simple, fancy) |
OPT_STYLE | the general type (e.g. memo, manual) |
Titles: | |
DOC_NAME | the title, excluding the type (e.g. SDF) |
DOC_TYPE | the title type (e.g. User Guide) |
DOC_AUTHOR | the author |
DOC_TOC | the number of heading levels in the table of contents |
Variables can be set via:
To undefine a variable, use the undef macro.
Variables are usually set in SDF by using the define macro. The format is:
!define symbol [expression]
Examples are:
!define LONG !define VERSION "1.002"
symbol is a sequence of letters, digits and underscore. If expression is omitted, the default value is 1.
It is often a good idea to only define a variable if it does not already have a value. To do this, use the default macro. The format is:
!default symbol [expression]
For example:
!default VERSION "1.002"
symbol is a sequence of letters, digits and underscore. If expression is omitted, the default value is 1.
Generally speaking, the first thing sdf does is to load the standard library (stdlib.sdm). However, if the first line of an SDF document is the init macro, the nominated variables are initialised before the standard library is loaded. This allows an SDF document to initialise variables used within the standard library. The format of the init macro is:
!init name1["="expression1]";" name2["="expression2] ...
For example:
!init OPT_STYLE="memo"
It is occasionally useful to set variables via sdf's -D option. Multiple definitions can be separated by commas. For example:
sdf -DLONG,VERSION="1.002" ...
Alternatively, the option can be repeated. For example:
sdf -DLONG -DVERSION="1.002" ...
In either case, if a value is not specified for a variable, 1 is assumed.
Contents | Parent Topic | Previous Topic | Next Topic
Home | Catalog