You can use local references in your web pages to create pages more efficiently.
Like standard references, local FML references always begin with the $ identifier.
The following examples are valid names for FML references:
$user_suggestion
$Usercalc
$Foo555
$Foo_bar
The #set command is used to set the value of a variable. For example:
|
#set ($animal = "bear") |
A reference can be set to another variable, a string literal, the property of another FML reference, a method, a number, or a List.
For example:
|
## reference |
You can also use #set for performing simple math on your web pages. More complex math should be performed inside the model.
For example:
|
#set( $value = $Run.SimStep + 1 ) |
When using the #set directive, string literals that are enclosed in double quote characters.
Strings will be parsed and rendered, using double-quotes, as shown:
|
<html> |
The output will be:
|
|
However, when the string is enclosed in single quote characters, it will not be parsed:
Example:
|
|
The output will be:
|
First Name = Sigmund |
Notice that with single quotes, $FirstName and $LastName are interpreted literally.
Strings can be set over multiple lines. The following example is perfectly valid:
|
#set ($teststring = |
The output of this example is (as you'd expect):
|
This is a test of |
Finally, note that you can combine strings with the + concatenation operator. For example:
|
#set ($first_name = "King") |
will display:
|
My name is King George. |
Of course, the same result could have been gotten without using the + operator with either of the examples below:
|
My name is $first_name $last_name. |
|
#set ($first_name = "King") |
But it's sometimes more convenient to use concatenation.