Was this helpful?
Built-in Functionality
 
FUNCTION
SYNTAX
EXAMPLE
--------------------
MEANING OF EXAMPLE
RESULTS
asc
asc(character )
asc(foo)
returns ASCII value of first character, in this case f
120
chr
chr(number)
chr(120)
returns ASCII character for ASCII value
f
cleararray
cleararray(array name)
cleararray(fVar)
clears all elements of an array
fix or int
fix(number)
int(35.6)
returns the integer portion of a number
35
gsub
gsub(reg expression, string, variable)
gsub(/\$/,"",$0)
$123.45 $22.50
replaces all dollar signs on the input line with empty string
123.45 22.50
initcaps
initcaps(string)
initcaps($0)
the end
makes first character of each word uppercase
The End
isnumeric
isnumeric (value)
isnumeric($3)
table number 12
returns 1 if the value in field 3 is a valid numeric value, 0 otherwise
true (1)
lcase
lcase(string)
lcase($0)
THE END of the Story
makes all characters in the input line lowercase
the end of the story
left
left(string, number)
left ($3,5)
zip code 78754-8565
returns the leftmost 5 characters from the third field
78754
length
length(string)
length($2)
table desk chair
returns the number of characters in the second field
4
logmessage
logmessage (type, format, parameter1, parameter2)
logmessage("WARN", "Problem on line %s", 3)
writes the message "WARN: Problem on Line 3" into the Map Designer log file
ltrim
ltrim(string)
ltrim($0)
the table and chair
deletes spaces from the left side of the input line without affecting other spaces on the line
the table and chair
namepart
NamePart (part of name, string)
NamePart("f", $0)
Mr. Roger P. Nelson
returns only the specified part of the name, first name, from the input line
Roger
readahead
readahead (number)
readahead(200)
reads more lines in the file until it reaches 200 bytes, then goes back to the input line it started on for the next pattern; returns a string containing the number of characters specified in the (number) parameter.
right
right(string, number)
right(4, $3)
zip code 78754-8565
returns the rightmost 4 characters from the third field
8565
rtrim
rtrim(string)
rtrim($1)
Mary Ann Wells
deletes spaces from the right side of the first field without affecting other spaces on the line
Mary Ann Wells
sgn
sgn(number)
sgn(55-100)
returns a value that indicates the sign of a number, -45 is the number, -1 indicates that it is negative
-1
shift
shift
table chair pen
$1 equals table
$2 equals chair
shift;
moves the input fields left one field, $3 becomes $2, $2 becomes $1, and the original $1 is lost
 
$1 equals chair
$2 equals pen
skip
skip(number)
skip(2);
causes the next 2 lines to not be processed
space
space(number)
$1 + space(5) + ($2$3)
Name: Joe Smith
returns a string of spaces the specified number long
Name: Joe Smith
split
split(string, array name, separator)
split($0, info, ":")
Name:Joe
divides a string and puts the parts in an array of the name specified, the separator determines where the string is divided, and the array is indexed with consecutive numbers
info[1] equals "Name"
info[2] equals "Joe"
string
string(number, string)
string(8, "*")
returns a string consisting of one character repeated the specified number of times, in this case an asterisk repeated 8 times
********
sub
sub(regular expression, string, variable)
sub(/c/,"C", $0)
count the cost of cats
replaces the first occurrence only of c in the input line
Count the cost of cats
substr
substr(string, position, length)
string($2,2,4)
cost $1432.56
returns a portion of a string, field 2, starting at position 2 and extending 4 positions
1432
transliterate
transliterate (Source character set, target character set, string)
transliterate("1234", "othf", $1)
894537281
replaces one set of characters with another in the first field
89f5h7t8o
trim
trim(string)
trim( " the end ")
deletes spaces from the left and right side of the string without affecting other spaces on the line
the end
ucase
ucase(string)
ucase($0)
the End
makes all characters in the input line uppercase
THE END
val
val(string)
a = val("9453")
returns numeric value for a string that can be read as numeric
a equals 9453
Individual descriptions of the functions above can be found in Language Syntax and Examples.
Last modified date: 02/01/2024