Maptitude GISDK Help |
Caliper Script supports three types of constants: numbers, strings, and the special constant, null. Boolean constants are a special case of numeric constants.
Numeric constants can be integer (whole numbers) or real (decimal numbers). Here are some examples:
7
429
231.546
0.0001
String constants are surrounded by single or double quotes. A string constant can be up to 254 characters. You can concatenate string constants to create longer strings, up to 2GB of characters. Here are some examples:
'Hello'
str = "Hello, " + 'there.' // str contains "Hello, there."
You must precede backslashes characters in string constants with the backslash character. If you use single or double quotes inside string constants enclosed by the same type of quotes, you must precede the single or double quotes with the backslash character. Here are some examples:
"c:\\mapt\\myfile.txt" // Stored as "c:\mapt\myfile.txt"
"The next three words \"are surrounded by\" double quotes" // Same type of quotes
"You're there!" // Different types of quotes
For readability, try using single quotes surrounding double quotes or the reverse, rather than backslash sequences. The following are equivalent:
"Select * where Abbr = \"MA\" and Population > 100000"
'Select * where Abbr = \'MA\' and Population > 100000'
"Select * where Abbr = 'MA' and Population > 100000"
'Select * where Abbr = "MA" and Population > 100000'
Note that some uses of strings may require double quotes rather than single quotes within the strings.
You can also insert a tab into a string constant with \t and a newline with \n. Other characters following the backslash are inserted without modification, but the backslash is omitted. These are conventions from C and C++, although those languages implement more sequences than does Caliper Script.
The null constant can be used freely in assignment statements and expressions, as in:
start_value = null
if list = null then dim list [100]
The string constants "True" and "False" are equivalent to the Boolean values of True and False, respectively. The following string and numeric constants also evaluate to True or False:
True |
False |
"Yes" |
"No" |
"On" |
"Off" |
1 |
null or 0 |
In addition, if the result of an arithmetic expression equals null or 0, the expression evaluates to False; all other results evaluate to True. Any statement that evaluates to True or False can be used as the test statement in an If or While statement.
Here is an example:
if CoordInScope(crd, scp) then do //returns "Yes" or "No"
// action
end
These constants, a literal syntax delimited by '/' characters, are only used in regular expressions. For more information, see Regular Expressions.
©2025 Caliper Corporation | www.caliper.com |