Multiple Choice Construct

The multiple choice construct of the Logic Template is used to determine which series of commands and assignments are to be processed. A multiple choice construct consists of an IF (x) statement (where x is a numerical expression to be evaluated), as the only item on a line, followed by one or more commands and/or assignments that are to be processed if the numerical expression x evaluates to anything other than zero. Those commands and/or assignments are followed an ELSE statement and a second set of one or more commands and/or assignments that are to be processed if the numerical expression x evaluates to zero. And, finally an ENDIF statement which terminates the construct.

When the IF (x) statement is encountered, the expression x is evaluated as a numeric expression. If the expression evaluates to zero, everything after the IF (x) statement up to the ELSE statement is ignored, and everything after the ELSE statement up to the ENDIF is processed. If the expression evaluates to anything other than zero, everything after the IF (x) statement up to the ELSE statement is processed, and everything after the ELSE statement up to the ENDIF is ignored. When the matching ENDIF statement is encountered, processing continues as it had before the IF (x) statement was encountered.

Multiple levels of nested parenthesis are supported within the numerical expression x. Within each pair of parenthesis can be any number of operands connected by any of the operators. Evaluation of the numerical expression x proceeds from the inner-most level of parenthesis outward, and then from left to right within each level. There is no precedence assigned to the operators.

Multiple choice constructs may be nested to any level and may be contained within and contain conditional processing constructs.

Format
IF
( cond )

listA

ELSE

listB

ENDIF

Item

Description

cond

The condition to be evaluated.

listA

List of commands and assignments to process if cond evaluates to anything other than 0.

listB

List of commands and assignments to process if cond evaluates to zero.

Example
Use a conditional processing construct nested within a multiple choice construct to select geo-spatial processing or relevancy processing of the results from a search request.

//Sort results by distance from a location if a set of coordinates has been loaded
//into the variable "Center"

IF ( Center )

//Search business names for those matching the expression found in the variable Keywords
//Turn off relevancy and weighting since it will not be used for sorting.

KeywordSearch( NONRESTRICTIVE, NameIndex, Keywords, OR, 1, 0 );

//Filter results to include those within a certain distance from a location
//if the distance is greater than 0.

IF ( 0 < Radius )

GeoRadialSearch( RESTRICTIVE, LocIndex, Center, Radius, 1, 0, MILES );

GeoCircFilter( CIRC_AND_INT, Field_X, Field_Y, Center, Radius, MILES );

ENDIF

GeoSpatialSort( Field_X, Field_Y, Center, 1 );

ELSE

//Search business names for those matching the expression found in the variable Keywords
//Turn on relevancy and weighting then use it for sorting the results.

KeywordSearch( NONRESTRICTIVE, NameIndex, Keywords, OR, 1, 1 );

IntrinsicWeightSort( 1 );

ENDIF