[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.4 $EXTRACT

Extracts a substring of a string.

The first argument is the source string.

The optional second argument specifies the starting position of the substring to extract, and defaults to 1.

The optional third argument specifies the ending position of the substring to extract, and defaults to the value of the second argument, or 1.

This example will extract the string FreeM into the local variable M.

SET NAME="FreeM is the best!"
SET M=$EXTRACT(NAME,1,5)

It is also possible to use $EXTRACT on the left-hand side of a SET assignment in order to modify a substring:

USER> SET FOO="ABCDEFG"


USER> SET $EXTRACT(FOO,1,3)="XYZ"


USER> WRITE FOO

XYZDEFG

This document was generated on November 11, 2022 using texi2html 5.0.