SETMID        Extract mid substring

Top  Previous  Next

Syntax:

SETMID

[ variable ]  =  [ value ] [ cnt ] [ at ]

Arguments:

[ variable ]

Variable to assign; if the variable does not previously exist it is created.

 

[ value ]

Variable or string defining the value from which the substring is to be extracted.

 

[ cnt ]

Variable, string, or numeric constant defining the length of the substring; this value must resolve to a numeric value less than or equal to the length of [ value ].

 

[ at ]

Variable, string, or numeric constant defining the position in [ value ] where the substring extraction is to begin; the first character in a string is at position 1.

Options:

none

 

 

 

This script command extracts [ cnt ] characters from within [ value ] beginning with character number [ at ] and saves the result in [ variable ].

 

Consider the following example.

 

;; assign a variable to a string

SET string = "this is a string"

;; extract 2 characters from mid-string starting at character #6

SETMID substring = string 2 6

 

;; another example of syntax to extract 2 characters from mid-string starting at character #6

SETNUM len = 2

SETNUM startat = 6

SETMID substring = string len startat

 

The resulting substring variable contains the value "is".

 

 

Related command(s):        SETRIGHT, SETLEFT, SETLEN, SETEXTRACT, SETSUBSTR, SET, SETREPLACE