A string register stores alphanumeric character strings. Each string register can hold a maximum of 254 characters. The default number of string registers is 25.
You can increase the number of string register at controlled start. Refer to the “System Operations” appendix of the Setup and Operations Manual for information on performing a controlled start.
There are several kinds of string register instructions:
String register assignment, SR[x]=
String register concatenation, SR[x]+
String register comparison, SR[x]<, >, =, <>, <=, >=
String register length, R[y]=STRLEN SR[x]
String register substring search, R[y]=FINDSTR SR[x], SR[z]
String register substring cut, SR[x]=SUBSTR SR[n],R[y],R[z]
String registers can be addressed using direct and indirect techniques. Please see Figure 6.46 in the Register Instructions section for more information.
SR[x] string register instructions manipulate the string register. The string register supports assignment and concatenation.
Examples of string register assignment instructions:
Examples of string register concatenation instructions:
String register instructions automatically convert numeric data types. This automatic conversion is explained in section Section 24.3, "String Conversion and Precedence" .
String and numeric data are automatically converted when using any register instruction.
Conversion from either integer or floating point numeric data is allowed. Floating point data will be rounded to 6 decimal places.
Examples of conversions from numeric to string data:
Table 26. SR[x]=R[y]
R[y] Value | SR[x] Result |
---|---|
R[y]=1234 | SR[x]=’1234’ |
R[y]=12.34 | SR[x]=’12.34’ |
R[y]=5.123456789 | SR[x]=’5.123457’ |
Conversion from strings to numeric data is allowed. An overflow alarm can occur if the maximum value for a floating point number is exceeded in the string representation. Conversion from string to numeric data will stop when the first alpha character is found.
Examples of conversions from string to numeric data:
Table 27. R[x]=SR[y]
SR[y] Value | R[x] Result |
---|---|
SR[y]=’1234’ | R[x] = 1234 |
SR[y]=’12.34’ | R[x]=12.34 |
SR[y]=’765abc’ | R[x]=765 |
SR[y]=’fgh’ | R[x]=0 |
There is data type conversion precedence when multiple conversions occur within an instruction. The data is converted to the data type of the left instruction for each operation.
Examples of conversion precedence:
Table 28. SR[x]=R[y]+SR[z]
R[y]=123.456 + SR[z]=’345.678’ | SR[x]=’456.134’ |
R[y]=456 + SR[z]='1abc2' | SR[x]='457' |
Table 29. SR[x]=SR[y]+R[z]
SR[y]=’123.’ + R[z]=345 | SR[x]=’123.345’ |
SR[y]=’xyz’ + R[z]=81573 | SR[x]=’xyz81573’ |
The STRLEN instruction will return the length of string stored in the specified register.
Example STRLEN usage:
Table 30. R[x]=STRLEN SR[y]:
SR[y] Value | R[x] Result |
---|---|
SR[y]=’abcdefghij’ | R[x]=10 |
SR[y]=’zyx1,2,3,4,5,6,lm’ | R[x]=17 |
SR[y]=’’ | R[x]=0 |
If STRLEN is used with an argument register, AR[x], whose data type is not a string a type mismatch alarm will occur.
The FINDSTR instruction will search the target string for the search string and returns the index within the target string. All string comparisons are case insensitive. If the search string is not found within the target string an index of zero, 0, is returned.
Example of FINDSTR usage:
Table 31. R[x]=FINDSTR SR[y],SR[z]
SR[z] Value with SR[y]=’We are searching for a string in this string’ | R[x] Result |
---|---|
SR[z]=’we’ | R[x]=1 |
SR[z]=’string’ | R[x]=24 |
SR[z]=’other’ | R[x]=0 |
SR[z]=’’ | R[x]=0 |
If FINDSTR is used with an argument register, AR[x], whose data type is not a string a type mismatch alarm will occur.
The SUBSTR instruction will return a substring from the target string based on the start point and length specified.
Example of SUBSTR usage:
Table 32. SR[n]=SUBSTR SR[x],R[y],R[z]
R[y] and R[z] Values with SR[x]=’This string will be broken apart.’ | SR[x] Result |
---|---|
R[y]=1,R[z]=4 | SR[x]=’This’ |
R[y]=28,R[z]=5 | SR[x]=’apart’ |
R[y]=8,R[z]=0 | SR[x]=’’ |
An overflow alarm will occur in any of the following conditions:
Starting point is less than or equal to zero
Length is less than zero
Starting point is greater than the target string length
Starting point plus length is greater than the target string length
If an argument register, AR[x], is used as the target string and whose data type is not a string, a type mismatch alarm will occur. If an argument register, AR[x], is used as the starting point or length and whose data type is not a numeric type mismatch alarm will occur.