Variable Assignments

Variable assignments in the Logic Template are used to enter new data into the system or to modify data already in the system. Many of the commands supported by Flexible Search require arguments to be passed as variables. Entering data into a field on an HTML form is one way to load a variable with the required data. Another way is to use a variable assignment within the logic template. For more information on HTML forms see the Display Template Reference Manual.

A variable assignment is made by placing the name of the variable in the far left column of a line, followed by an equals sign, followed by an expression, followed by the line terminating semi-colon. Any amount of whitespace may be present between the equals sign and either the variable name or expression. The white space is ignored.

Variables are not declared or assigned a type. Variables come into existence when passed in as part of the query string or created by a variable assignment. All variables are of the type text, which means they can hold text or text string data. However, variables may be of more than one type. If the text string contained within the variable defines a date or time, the variable can be thought of to be a datetime variable. If the text string within the variable defines an integer or fixed point value, the variable can be thought of to be a numeric variable.

If a variable is being created by the variable assignment, the expression to the right of the equals sign is evaluated and assigned to the variable. If the variable already exists prior to the variable assignment, the expression to the right of the equals sign is evaluated and concatenated to the text string within the variable, with a single intervening space.

For any variable, the expression to the right of the equals sign can be a text string literal, dynamic text string or a string function.

For date-time variables, the expression to the right of the equals sign can be a date-time literal or a dynamic date-time value.

For numeric variables, the expression to the right of the equals sign can be a numeric literal, dynamic value or a numeric function.

A variable can also be assigned a date-time range, a numeric range, a spatial coordinate, a geo-spatial coordinate, a spatial rectangle, or a geo-spatial rectangle -- in order to be used as an argument to a search, filter, or sort command. When assigned one of these special data types, the variable contents are undefined for other uses.

The following are examples of variable assignments:

Variable Assignment

Variable

Contents

DATA_1 = 33;

DATA_1

"33"

DATA_2 = ( DATA_1 + 12 );

DATA_2

"45"

DATA_2 = "BOXES";

DATA_2

"45 BOXES"

DATA_3 = "HELLO";

DATA_3

"HELLO"

DATA_3 = "BILL";

DATA_3

"HELLO BILL"

DATA_4 = ( 3 + 12 );

DATA_4

"15"

DATA_5 = "( 3 + 12 )";

DATA_5

"( 3 + 12 )"

DATA_5 = "=";

DATA_5

"( 3 + 12 )="

DATA_5 = ( 3 + 12 );

DATA_5

"( 3 + 12 )=15"

DATA_6 = "$"( DATA_1 + 4 );

DATA_6

"$37"

DATA_7 = "$( DATA_1 + 4 )";

DATA_7

"$( DATA_1 + 4 )"

Examples
//Assign an asterisk to a search string if it is empty

IF ( ! _SearchString )

_SearchString = "*";

ENDIF

//Assign a numeric range to a variable for use in searching
_Range
= [301 :: 400];

//Assign a geo-spatial rectangle to a variable for use in searching
_Rectangle
= {{ -82.232, 30.233 }, { -81.985, 29.679 } };