Dynamic variables allow to have custom content of the bbs, depending on various dynamic parameters.
For example, it is possible to show the network address of the client machine when loading the forum.
It is also possible to use the same templates for different forums and change the forum's title,
depending on the data alias used.
The syntax of dynamic variables is:
<!--DYNAMIC--expression-->
|
There's a range of pre-defined variables:
Table 5-1. aGNeS Variables
| HOUR |
current server hour |
| MIN |
current server minute |
| DAY |
current server day |
| MONTH |
current server month |
| YEAR |
current server year |
| TIME |
$hour:$min |
| DATE |
$day/$month/$year |
| IP |
network address of the remote machine |
| ALIAS |
alias used for forum data, the name of your bbs |
| TEMPLATE |
template used for the forum layout |
A variable name is a well defined entity beginning with a $ sign,
followed by a series of alphanumeric elements, dots and dashes.
For example, $time
is a variable and is being translated into the current
time. For example:
Variables use the following general syntax:
{$£}{name}[|COMMAND{PARAMETER}]~[Prefix]#[Postfix]^[Elsefix]
|
To output a variable value, simply use it with a $ sign, for example
$ip
.
To evaluate a variable, use it with a £ sign, for example
£ip~[Do not know remote ip!]
.
As you might have guessed, the final result will be "Do not know remote ip!"
if the variable
ip
contains any text and nothing will be output when it is empty.
In general, if the variable is empty, Elsefix
is output.
Otherwise, Prefix
is inserted before and Postfix
,
after the variable value. Any of the three sections Prefix
,
Postfix
or Elsefix
can me omitted.
Commands allow to pre-operate on the variable. This means that the variable value will be affected before
it is checked for having any data for the Prefix
, Postfix
or
Elsefix
output. You can chain commands by separating them with a comma.
Commands can be one, or a combination of the following:
Table 5-2. Expression Commands
| TRIM |
remove leading and trailing spaces |
| TRIM32 |
remove leading and trailing spaces, carriage returns, tabs and line feeds |
| LEFT{SIZE} |
leave leftmost SIZE characters |
| RIGHT{SIZE} |
leave leftmost RIGHT characters |
| IS{STRING} |
clear if not STRING (case-sensitive) |
| NOT{STRING} |
clear if STRING (case-sensitive) |
| HAS{STRING} |
clear if does not contain STRING (case-insensitive) |
| STARTS{STRING} |
clear if does not start with STRING (case-insensitive) |
| ENDS{STRING} |
clear if does not end with STRING (case-insensitive) |
| UPCASE |
convert to upper-case |
| LCASE |
convert to lower-case |
| REVERSE |
reverse value |
| MORE{NUMBER} |
clear if term is smaller or equal to NUMBER (leave unchanged if more than NUMBER) |
| LESS{NUMBER} |
clear if term is bigger or equal to NUMBER (leave unchanged if less than NUMBER) |
| CLEFT{NUMBER} |
cut the NUMBER leftmost characters |
| CRIGHT{NUMBER} |
cut the NUMBER rightmost characters |
The easiest way to understand how expressions work in aGNeS is to look at examples with the following data:
Table 5-3. Variable Values
| Variable Name |
Variable Value |
| search |
foo |
| url |
http://www.foo.com/bar/ |
| dummy |
|
| quant |
10 |
Table 5-4. Expression Examples
| Expression |
Output |
| $dummy~[Dummy is empty...]^[Dummy is not empty...] |
Dummy is empty... |
| Searching for "$search", $quant results found. |
Searching for "foo", 10 results found. |
| $quant~[Found ]#[ documents.]^[No documents found.] |
Found 10 documents. |
| £search~[Searching $search\.]^[Nothing to search!] |
Searching foo. |
| $url|TRIM,LEFT10 |
http://www |
| £url|[HASftp://]~[Ftp!]^
[£url|[STARTShttp://]~[Web!]] |
Web! |