Trail: PROIV Documentation > Developer > PROIV Developer > Developing Functions > Events and Logic > IN-LINE SUBSTRINGING

 

 

Purpose

IN-LINE SUBSTRINGING retrieves a portion of an alphanumeric or wide string.
 

Syntax

operand1(operand2,operand3{,operand4})
 

Operation

operand1 if on the left side of an assignment, is any valid alphanumeric or wide character string variable; otherwise, it is any valid alphanumeric or wide character string constant, variable, or expression.
operand2
 is any valid numeric constant, variable, or expression which represents the starting position (in terms of bytes for alphanumeric strings, and characters for wide strings) within operand1.
operand3
is any valid numeric constant, variable, or expression which represents the ending position (in terms of bytes for alphanumeric strings, and characters for wide strings) within operand1.
operand4
 
is optional, and when used must be set to “NLS". This operand enables you to locate a sub-string in a mixed multi-byte string (e.g. a string that contains both WIDE and normal ALPHA characters). The use of this option is recommended for any applications that may use multi-national code sets.
 

Remarks

The value returned is alphanumeric or wide and of the same type as operand1.  If operand3 is greater than the number of characters in operand1, operand1 is appended with spaces to make it up to the length specified in operand3.
 

Example 1

The following logic routine is used to parse the field NAME into first and last name.

#X = INDEX(NAME,’ ‘)
IF #X = 0 THEN
            LAST = NAME
ELSE
            FIRST = NAME(1,#X-1)
            LAST = NAME(#X+1,LEN (NAME))
ENDIF

Prior to processing the logic, the fields contain the following values:
NAME = the last name only or the first name followed by the last name
LAST  = null
FIRST = null
#X     =  zero

After processing the logic, the fields contain the following values:
NAME  unchanged.
LAST  = the last name from field NAME.
FIRST = the first name from field NAME if one exists, otherwise it remains null.
#X     = the position of the space in the field NAME if a first name was provided in field NAME,
      otherwise it remains zero.
 

Example 2

The following logic routine is used to replace the month in a date string by another month.

$DATE(6,13) = $NEWMONTH

Prior to processing the logic, the fields contain the following values
$DATE          = 21st December
$NEWMONTH = June

After processing the logic, the fields contain the following values:
$DATE          = 21st June
$NEWMONTH = June
 

Example 3

The following logic routine appends six spaces to the value in $NAME, and then replaces characters 5 to 9 of the resulting string by the string in $SECONDNAME.

$NAME(5,9) = $SECONDNAME

Prior to processing the logic, the fields contain the following values:
$NAME              = Tom
$SECONDNAME  = Brown

After processing the logic, the fields contain the following values:
$NAME              = Tom Brown
$SECONDNAME  = Brown
 

Comment on this topic

Topic ID: 520068

 
 
 

Table of Contents

Index

Glossary

-Search-

Back