SETSUBSTR Find number of substrings in string
<< Click to Display Table of Contents >> Navigation: Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands > SETSUBSTR Find number of substrings in string |
Syntax: |
SETSUBSTR |
[ variable ] = [ string ] [ substr ] |
Arguments: |
[ variable ] |
Variable to assign; if the variable does not previously exist it is created. |
|
[ string ] |
Variable or string defining the value of string from which to obtain the delimiter count. |
|
[ substr ] |
Variable or string defining the delimiter string to search for within [ string ]. A delimiter can be one or more characters in length. |
Options: |
None |
|
This script command searches [ string ] for occurences of [ substr ] and saves the number of occurences found in [ variable ].
The following example uses SETSUBSTR to determine if a filename has no extension:
SET filename = "MyData"
SETSUBSTR dots = filename "."
IFNUM= dots 0 GOTO no_extension
The following example finds the number of file name segments:
SET filename = "data.temporary.sbc.xml"
;; find how many "." occur
SETSUBSTR dots = filename "."
;; the number of segments is one more than the number of dots
SETNUM segments = dots + 1
The SETSUBSTR command can be used to detect and remove unwanted characters (see: Rename files during download) from the names of files to be downloaded. The SETEXTRACT and SETRIGHT commands are also useful for parsing a filenames.
Related command(s): SETEXTRACT, IFSUBSTR, SET, SETRIGHT, SETLEFT, SETLEN, SETMID, SETREPLACE