Previous Topic

Next Topic

Book Contents

Book Index

%%SUBSTR

The %%SUBSTR function extracts a substring from a string.

The format of the %%SUBSTR function is

%%SUBSTR string startpos length

where

A new string is created composed of the characters extracted from the original string.

startpos and length must be a numeric value or AutoEdit expression that is greater than zero.

When the starting position of the substring is greater than the argument string, the function returns a null value.

When the starting position of the substring falls within the argument string, but the length of the substring falls outside the range of the argument string (startpos + length – 1), the function returns a substring containing the characters from the starting position.

If the character positions of startpos + length – 1 is greater than the string length, submission of the member is stopped.

Example 1

//* %%SET %%A=%%$CALCDTE %%$ODATE -1

//* %%SET %%AMON=%%SUBSTR %%A 5 2

On July 1, 2001:

%%A is assigned a value of 20010630

%%AMON is assigned a value of 06

Example 2

%%SET %%A=%%SUBSTR CABLE 4 4

resolves to

%%A=LE

Parent Topic

Functions