String and Basic Math Commands
Below are commands related to string operations.
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.
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.
Syntax: concat variable_name string1 string2 string3…
This command concatenates a list of strings and stores the result in the variable “variable_name”.
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.
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.
Syntax: upcase variable_name
This command converts variable "variable_name" to all upper case characters.
Syntax: locase variable_name
This command converts variable "variable_name" to all lower case characters.
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.
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.
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.
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".
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.
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".
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".
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".