STRING GroupName[32], Filename[256]
STRING GroupNames[32](VIRTUAL)
STRING Names[80](3)
STRING picklist[VIRTUAL]
Initialization
GroupName = “MyGroup”
The string comparison operators are special in that they ignore trailing blanks and uppercase and lowercase. Therefore, all of the following expressions are TRUE
“ABC” == “ABC “
“ABC” == “abc”
Leading blanks are compared, i.e., “TEST” != “ TEST”
To perform case sensitive comparisons use the str_equal() function, i.e.,
IF (str_equal(GroupName1, GroupName2)) THEN RETURN 0
Functions
str_length(MyString)
DESCRIPTION
Returns the current length of a PCL string.
INPUT
|
|
|
MyString
|
String[]
|
String for which to return the length.
|
OUTPUT
|
|
|
|
Integer
|
Length of MyString.
|
EXAMPLE
length = str_length(“abcde”)
length -> 5
str_substr(MyString, Position, Length)
DESCRIPTION
Return a portion of the input string from the specified position of the specified length.
INPUT
|
|
|
MyString
|
String[]
|
String to extract the substring from. The input string is not modified.
|
Position
|
Integer
|
Starting position in the string where 1 is the first position.
|
Length
|
Integer
|
Number of characters to extract
|
OUTPUT
|
|
|
|
String[]
|
Extracted substring of the input string.
|
EXAMPLES
NewString = str_substr(“abcde”, 1, 2)
NewString -> “ab”
NewString2 = str_substr(“abcde”, 4, 10)
NewString2 -> “de”
str_assign(MyString, Position, Length, MyString2)
DESCRIPTION
Replace a portion of a string with another string.
INPUT
|
|
|
MyString
|
String[]
|
Original string to be modified. This parameter will be modified.
|
Position
|
Integer
|
Starting position within MyString where insertion will take place.
|
Length
|
Integer
|
Number of characters to be replaced.
|
MyString2
|
String[]
|
String that will be substituted into MyString.
|
OUTPUT
|
|
|
MyString
|
String[]
|
The original string (MyString) with a portion of MyString replaced by MyString2.
|
EXAMPLES
MyString = “abxyzf”
str_assign(MyString, 3, 3, “cde”)
MyString -> “abcdef”
str_index(MyString1, MyString2)
DESCRIPTION
Return the position where a string is found within another string.
INPUT
|
|
|
MyString1
|
String[]
|
String within which to find an occurrence of the second string.
|
MyString2
|
String[]
|
String to look for within the first string.
|
OUTPUT
|
|
|
|
Integer
|
Position where MyString2 was found within MyString1 where 1 is the first position. Zero is returned if the string is not found
|
EXAMPLES
Position = str_index(“abcdef”, “cde”)
Position -> 3
Position = str_index(“abcdef”, “xyz”)
Position -> 0
str_token(MyString, Delimiter, Ntoken[, Compress])
DESCRIPTION
Extracts a token (a sequence of characters) marked off by a delimiting character from a string.
INPUT
|
|
|
MyString
|
String[]
|
Source string from which the string tokens will be extracted.
|
Delimiter
|
String[1]
|
Single character token string.
|
Ntoken
|
Integer
|
Which token to extract. This must be at least 1.
|
Compress
|
Logical
|
Optional. If TRUE then empty tokens will be ignored.
|
OUTPUT
|
|
|
|
String[]
|
Extracted token string from the input string. Leading and trailing spaces are deleted if the delimiter is not a space.
|
EXAMPLE
TmpString = str_token(“abc, def, hij”, “,”, 2)
TmpString -> “def”
TmpString2 = str_token(“*CLASS = MyClass”, “=”, 2)
TmpString2 -> “MyClass”
str_strip_lead(MyString)
DESCRIPTION
Return a copy of the string with the leading spaces removed.
INPUT
|
|
|
MyString
|
String[]
|
Input string with leading spaces.
|
OUTPUT
|
|
|
|
String[]
|
Output string with no leading spaces.
|
EXAMPLE
MyString2 = str_strip_lead(“ a b c”)
MyString2 -> “a b c”
str_strip_trail(MyString)
DESCRIPTION
Return a copy of the string with the trailing spaces removed.
INPUT
|
|
|
MyString
|
String[]
|
Input string with trailing spaces.
|
OUTPUT
|
|
|
|
String[]
|
Output string with no trailing spaces.
|
EXAMPLE
MyString2 = str_strip_trail(“ a b c ”)
MyString2 -> “ a b c”
str_to_integer(MyString[, status])
DESCRIPTION
Convert a string to an integer.
INPUT
|
|
|
MyString
|
String[]
|
Input string.
|
OUTPUT
|
|
|
status
|
Integer
|
Optional. Zero for success or the position within MyString where the first invalid character occurs.
|
|
Integer
|
Integer value.
|
EXAMPLE
ival = str_to_integer(“12”)
ival -> 12
str_from_integer(ival)
DESCRIPTION
Convert an integer to a string.
INPUT
|
|
|
ival
|
Integer
|
Input integer value.
|
OUTPUT
|
|
|
|
String[]
|
String value.
|
EXAMPLE
MyString = str_from_integer(12)
MyString -> “12”
str_datatype(MyString)
DESCRIPTION
Attempt to decipher the datatype contained in a string.
INPUT
|
|
|
MyString
|
String
|
Input string.
|
OUTPUT
|
|
|
|
String[]
|
String representing the datatype, i.e., “INTEGER”, “REAL”, “LOGICAL”, or “STRING”.
|
OTHER FUNCTIONS
str_to_real(MyString[, status])
str_from_real(RealValue)
str_to_logical(MyString)
str_from_logical(LogicalValue)
Share with your friends: |