SETLEFT Extract left substring
<< Click to Display Table of Contents >> Navigation: Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands > SETLEFT Extract left substring |
Syntax: |
SETLEFT |
[ variable ] = [ value ] [ cnt ] [ /options ] |
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 ]. |
Options: |
/split |
Save the unextracted portion of the string back in [ value ]. |
This script command extracts the leftmost [ cnt ] characters from [ value ] and saves the result in [ variable ].
If the /split option is specified, the unextracted portion of [ value ] is assigned back to [ value ] replacing the original value.
Consider the following example.
;; assign a variable to a string
SET string = "this is a string"
;; extract the leftmost 4 characters
SETLEFT substring = string 4
;; another example of syntax to extract the leftmost 4 characters
SETNUM len = 4
SETLEFT substring = string len
The resulting substring variable contains the value "this". The original string variable is unchanged.
Consider the same example using the /split option.
;; assign a variable to a string
SET string = "this is a string"
;; extract the leftmost 4 characters
SETLEFT substring = string 4 /split
The resulting substring variable contains the value "this" and the original string variable becomes " is a string".
Related command(s): SETRIGHT, SETMID, SETLEN, SETEXTRACT, SETSUBSTR, SET, SETREPLACE