Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 3 Tools : SUBSTRING

SUBSTRING
Returns a selected portion of a string. (F)
Invocation
subsequence = SUBSTRING(string, start, length)
 
On return, contains the selected portion of the string. Its syntax is the same as string except that, if string is C (fixed-length character string), subsequence becomes V (variable-length character string).
The string to select characters from. Its syntax can be C, UN (Unicode), V, or W (double-byte character).
An integer specifying the position of the first character of the subsequence. Its syntax is B (binary) with length 4. Its value must be greater than zero. A value of 1 indicates the first character of the string.
An integer specifying the number of characters to select. Its syntax is B (binary) with length 4. Its value must be equal to or greater than zero.
Usage Notes
If start plus length is greater than the length of string, SUBSTRING raises an error condition.
Example
This rule extracts a subsequence from a string and prints to the message log:

 
RULE EDITOR ===> SCROLL: P
SUBSTRING_1;
_ LOCAL SOURCE_STRING, SUBSEQ_STRING;
_ ---------------------------------------------------------------------------
_ --------------------------------------------------------------+--------------
_ SOURCE_STRING = 'THIS IS A STRING'; | 1
_ SUBSEQ_STRING = SUBSTRING(SOURCE_STRING, 2, 3); | 2
_ CALL MSGLOG('THE SUBSTRING IS: ' || SUBSEQ_STRING); | 3
_ CALL MSGLOG('THE SOURCE STRING IS STILL: ' || SOURCE_STRING); | 4
_ ---------------------------------------------------------------------------

 
Resulting Output
Pressing PF2 after executing this rule displays the following:

 
--------------------- INFORMATIONAL MESSAGE LOG ----------------------
COMMAND ===> SCROLL ===> P
THE SUBSTRING IS: HIS
THE SOURCE STRING IS STILL: THIS IS A STRING

 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved