Was this helpful?
Expressions in Statements
Most statements are made up of expressions of various kinds. An expression is formed by combining operators with constants, variables, array references, function calls, and field names. All of these combinations are discussed in detail in the following topics:
Comment Statements
Comments begin with the pound sign character # and continue until the end of the line. Blank lines may be used to separate statements.
Example
# This comment statement would take the entire line
BEGIN { counter = 0; } #
BEGIN pattern-action block,
this comment takes 1/2 the line
Reinitialize Statement
The CLEARVARS statement will set all variables to appropriate initial values; numeric variables to 0, string variables to null. However, built-in variables will not be initialized.
Assignment Statements
Assignment statements are any statements that use the assignment operators:
= += -=
Built-in variables are assigned values automatically. Other variables are assigned values by equating them to numbers, strings, or expressions. Expressions can be arithmetic, string concatenations, or functions involving variables, numbers, or strings.
Example 1
The variable counter is incremented by one each time this statement is executed.
counter += 1;
Example 2
The variable header will contain the value of the variable date surrounded by two text strings. The right side of this statement is a string expression.
header = "Progress Report as of " + date + " for Project Eight.";
Example 3
The variable city will contain the value of the substring in the 12th through the 23rd character of the input line:
city = $0(12 23);
Catchup Statements
Catchup statements are use to turn CATCHUP mode on and off. The CATCHUP pattern is matched and the corresponding action block performed when CATCHUP mode is turned on. The CATCHUP action block processes until CATCHUP mode is turned off. The statement catchup on; will turn on CATCHUP mode, causing the action associated with the CATCHUP pattern to be executed. The statement catchup off; will turn off CATCHUP mode, causing normal processing to continue where it left off. For more information, see the sections CATCHUP {statements}, catchup on, and catchup off in Language Syntax and Examples.>>
Control Statements
In CXL, the Control Statements support the following functionality:
Decision-making flow of statements with the if-else statement.
Iterating over all elements of an array with the for statement.
Repeating the execution of a group of statements until an expression evaluates to false with the while statement.
Grouping multiple statements into a single block with { }.
Terminating the processing of the current input line with the break and reject statements.
Terminating the processing of the script with the stop statement.
Detailed descriptions and examples using each of these Control Statements can be found in Language Syntax and Examples
Output Statements
Write output information to the Map Designer with the accept statement.
Detailed descriptions and examples using accept can be found in Language Syntax and Examples
Last modified date: 12/03/2024