Below are commands related to string and basic math operations.



splitfields

Syntax: splitfields variable <delimiter> <quoter>

This command splits the contents of variable "variable" into separate fields. By default, the space (ascii #32) character is used to delimit the fields. The optional ‘delimiter’ parameter can be used to change the delimiter. When the delimiter is a space, the non-breaking space character (ascii #160) is also considered a delimiter - this character is commonly contained in strings used by web or social media applications. Other commonly used delimiters are a comma and a tab. Use the variable TAB to specify the tab character.

Fields that might contain the delimiter character are kept as one field if they are surrounded by a quoter character, which defaults to the double-quote character ("). The ‘quoter’ parameter can be used to quoting character.

The fields are accessed with the getfield command and the number of fields found is stored in the NUMFIELDS variable. The maximum number of fields that are allowed is 50.

getfield

Syntax: getfield variable fieldno

This command sets the variable ‘variable’ to the field ‘fieldno’ previously set by the splitfields command. Field numbers start with 1.

concat

Syntax: concat variable_name string1 string2 string3…

This command concatenates a list of strings and stores the result in the variable “variable_name”.

cropstring

Syntax: cropstring cropped first last string

This command crops the string "string" starting with character "first" and ending with character "last". The first character is 1. The variable "cropped" is set to the result. If "first" or "last" are out of range or invalid numbers, a fatal error will occur.

trimleft

Syntax: trimleft variable_name

This command removes leading space characters from the variable "variable_name".

trimright

Syntax: trimright variable_name

This command removes trailing space characters from the variable "variable_name".

scanstring

Syntax: scanstring index_variable_name search_string string <ignorecase>

This command scans for "search_string" within "string". If the "search_string" is found, the variable "index_variable_name" is set to the index of its first character (starting with 1), otherwise it is set to 0. If "ignorecase" is "true", the search is not case-sensitive.

stripstring

Syntax: stripstring variable_name char

This command converts removes the "char" characters from the variable "variable_name". If "char" contains more than one character, only the first character is used.

replacestring

Syntax: replacestring variable_name string searchstring replacestring

This command replaces characters of "string" that match "searchstring" with "replacestring". All occurrences are replaced.

upcase

Syntax: upcase variable_name

This command converts variable "variable_name" to all upper case characters.

locase

Syntax: locase variable_name

This command converts variable "variable_name" to all lower case characters.

round

Syntax: round variable_name <digits>

The variable ‘variable_name’ is rounded to the nearest integer or to the specified number of "digits". The result returned to "variable_name". The  A fatal error occurs if 'variable_name' was not a valid number.

squareroot

Syntax: squareroot variable_name

The variable ‘variable_name’ is set to the square root of its current value. The  A fatal error occurs if 'variable_name' was not a valid number or less than 0.

abs

Syntax: abs variable_name <digits>

The variable ‘variable_name’ is set to its absolute value rounded to the nearest integer or to the specified number of "digits". The result returned to "variable_name". The  A fatal error occurs if 'variable_name' was not a valid number.

padinteger

Syntax: padinteger variable_name digits

This command pads the integer number in "variable_name" to at least "digits" characters. For example, 'padinteger COUNT 5', with variable COUNT containing "34", variable COUNT would become "00034". If an error occurs, the variable NUMERICERROR is set to "true".

getstringlength

Syntax: getstringlength string
Syntax: setstringlength string (legacy - do not use)

This command counts the number of characters in the string "string"and stores the result in the variable STRINGLENGTH.

validatenumber

Syntax: validatenumber number min max

This command validates that 'number' is a valid number and is greater than or equal to "min" and less than or equal to "max". If not valid, the variable NUMERICERROR is set to "true".

validateinteger

Syntax: validateinteger integer min max

This command validates that 'integer' is a valid integer and is greater than or equal to "min" and less than or equal to "max". If not valid, the variable NUMERICERROR is set to "true". "min" and "max" must be integers too.

validatera

Syntax: validatera ra

This command validates that "ra" is a valid right ascension number (ie. 0-24 hours). The format can be in decimal, hours:minutes, or hour:minutes:seconds. Valid examples are: 12:34.0, 12:34:56, 12:34, 12:34:56.7. Use this command before assigning a right ascension to the RA variable or where any other  right ascension value is used, otherwise a fatal error may occur. If not valid, the variable NUMERICERROR is set to "true".

validatedec

Syntax: validatedec dec

This command validates that "dec" is a valid declination number (ie. -90 to +90 degrees). The format can be in decimal, degrees:minutes, or degrees:minutes:seconds. Valid examples are: +12:34.0, 12:34:56, -12:34, +12:34:56.7. Use this command before assigning a declination value to the DEC variable or where any other declination value is used, otherwise a fatal error may occur. If not valid, the variable NUMERICERROR is set to "true".

convertdatetime

Syntax: convertdatetime yyyy-mm-dd
Syntax: convertdatetime "yyyy-mm-dd hh:mm:ss"
Syntax: convertdatetime "yyyy/mm/dd hh:mm:ss"
Syntax: convertdatetime yyyy/mm/dd
Syntax: convertdatetime "yyyy mm dd"
Syntax: convertdatetime "yyyy mm dd hh mm ss"

This command converts a date or date and time string to the variables: YEAR, MONTH, DAYOFMONTH, HOUR, MINUTE, and SECOND. If the time is not included, it is set to 00:00:00.  If an error occurs, the variable NUMERICERROR is set to "true".

md5string

Syntax: md5string variable_name string

This command converts "string" into a 32-hex-character MD5 encrypted hash string and stores it in "variable_name".

parsexmlnodename

Syntax: parsexmlnodename xml nodename

This command parses the XML-formatted string "xml" and extracts the node named "nodename". The variables set are:

  • XMLTEXT is set to the raw XML of the node name found
  • XMLVALUE is set to the node's text value (null if no valid text value)
  • XMLCOUNT is set to the number of nodes in the input XML
  • XMLERROR is "true" if an error occurs

parsexmlindex

Syntax: parsexmlindex xml index

This command parses the XML-formatted string "xml" and extracts the node number "index" (the first node is 1). The variables set are:

  • XMLTEXT is set to the raw XML of the node extracted
  • XMLVALUE is set to the node's text value (null if no valid text value)
  • XMLCOUNT is set to the number of nodes in the input XML
  • XMLERROR is "true" if an error occurs