EQWatcher Evolution > Scripting  > String Manipulation


List of commands


asc, atoi, chr, itoa, left, LowerCase, mid, Reverse, right, strcat, strchr, strcmp, strcmpN, strlen, strnchr, strpos, strrchr, substr, substrN, UpperCase



The "asc" Command

This command converts string data to char data.

Syntax:

asc([String])


String: A string, assuming that the first character in the string is the one to be retrieved (converted directly to a char type), such as "A"


Return Value:

This command returns a char corresponding to the first character in the string.  The string can be any length -- if its length is 0, the return value will be 0.  In the example shown, the return value would be 65, which is the same as 'A'.


The "atoi" Command

This command converts string data to integer data.

Syntax:

atoi([Data])


Data: A string containing a number you wish to retrieve, such as "1234".


Return Value:

This command returns the integer value found in the string (base 10).  In the example given, this value would be 1234.


The "chr" Command

This command converts char data to string data.

Syntax:

chr([Char])


Char: A char (0-255) value you wish to convert to string, such as 'A' or 97.


Return Value:

This command returns a string containing the ASCII character from the number supplied.  In the example given, the value would be "A".


The "itoa" Command

This command converts integer data to string data.

Syntax:

itoa([Data])


Data: An integer value you wish to convert to string, such as 1234.


Return Value:

This command returns a string containing the number from Data.  In the example given, the return value would be "1234".


The "left" Command

This command retrieves a string of characters from the left end of a string.

Syntax:

left([Data],[Length])


Data: The string with data to be retrieved.

Length: The number of characters to be retrieved.


Return Value:

This command returns a string containing the left Length characters of the string Data.


The "LowerCase" Command

This command converts string data to all lower case.

Syntax:

LowerCase([Data])


Data: The string you wish to convert, such as "JOBOBER".


Return Value:

This command returns a string containing the lower case version of Data.  In the example given, the return value would be "jobober".


The "mid" Command

This command retrieves a string of characters from the middle of a string.

Syntax:

mid([Data],[Index],[Length])


Data: The string with data to be retrieved.

Index: The zero-based index of the string position to begin retrieving data from.

Length: The number of characters (length of the new string) to be retrieved.


Return Value:

This command returns a string containing  Length characters of the string Data, starting with the character at Index.


The "Reverse" Command

This command reverses a string.

Syntax:

Reverse([Data])


Data: The string you wish to reverse, such as "abcdefg".


Return Value:

This command returns a string containing the reversed version of Data.  In the example shown, the result would be "gfedcba".


The "right" Command

This command retrieves a string of characters from the right end of a string.

Syntax:

right([Data],[Length])


Data: The string with data to be retrieved.

Length: The number of characters (length of the new string) to be retrieved.


Return Value:

This command returns a string containing the right Length characters of the string Data.


The "strcat" Command

This command concatenates, or adds together, strings.

Syntax:

strcat([Destination],[Data 1],[Data 2], . . .[Data 6])


Destination: The string to serve as the destination.  Each following Data is appended to this string.

Data: Up to 6 strings to concatenate.  These may be any variable type, and conversion to string data is automatically done.


Return Value:

This command returns the Destination string.


The "strchr" Command

This command replaces a specified char by position in a string.

Syntax:

strchr([Data],[Char],[Index])


Data: The string with data to be modified.

Char: The char value to store at this index.

Index: The zero-based index of the position to replace.



The "strcmp" Command

This command compares two strings, case sensitive.

Syntax:

strcmp([String A],[String B])


String A: The first string to be compared.

String B: The second string to be compared.


Return Value:

This command returns a signed long value, one of these three:


-1: String A is alphabetically before String B

0: String A is alphabetically equal to String B

1: String A is alphabetically after String B



The "strcmpN" Command

This command compares two strings, NOT case sensitive.

Syntax:

strcmpN([String A],[String B])


String A: The first string to be compared.

String B: The second string to be compared.


Return Value:

This command returns a signed long value, one of these three:


-1: String A is alphabetically before String B

0: String A is alphabetically equal to String B

1: String A is alphabetically after String B



The "strlen" Command

This command retrieves the length of a string.

Syntax:

strlen([Data])


Data: The string with length to be checked.


Return Value:

This command returns the length of Data.


The "strnchr" Command

This command finds the nth instance of a character within a string (i.e. finding the 4th instance of "a" in "abcdefgabcdefgabcdefgabcdefgabcdefg").

Syntax:

strnchr([String],[Index],[Char])


String: The string you wish to search

Index: The number n where the nth instance of the char value is to be found

Char: The char value to search for


Return Value:

This command returns the position (strpos) within the string that the char value is found at (will return 0 if the nth instance is not found or the string is empty).


The "strpos" Command

This command retrieves a specified char value in a string.

Syntax:

strpos([Data],[Index])


Data: The string with data to be retrieved.

Index: The zero-based index of the char value to retrieve.


Return Value:

This command returns the char value at Index of Data.


The "strrchr" Command

This command replaces all instances of a specific char value with another char value.

Syntax:

strrchr([String],[Before],[After])


String: The string you wish to search

Before: The char value to be replaced with After

After: The char value to replace Before


Return Value:

This command returns the number of replacements made.


The "substr" Command

This command searches for a substring within another string, case sensitive.

Syntax:

substr([Data],[Substring],[Index])


Data: The string with data to be searched.

Substring: The string to search for in Data.

Index: The zero-based index of the position to begin the search.


Return Value:

This command returns the index of the position that begins the matched Substring.  If there is no match, -1 is returned.


The "substrN" Command

This command searches for a substring within another string, NOT case sensitive.

Syntax:

substrN([Data],[Substring],[Index])


Data: The string with data to be searched.

Substring: The string to search for in Data.

Index: The zero-based index of the position to begin the search.


Return Value:

This command returns the index of the position that begins the matched Substring.  If there is no match, -1 is returned.


The "UpperCase" Command

This command converts string data to all upper case.

Syntax:

UpperCase([Data])


Data: The string you wish to convert.


Return Value:

This command returns a string containing the upper case version of Data.