Script SUBSTR Function

SUBSTR (_var, begin, length)

SUBSTR is a function that takes a string of characters in a variable and returns a "substring" or portion of the string. The returned  substring begins with character number begin and continues for length characters. Begin and length may be literal numbers or variables. For example, the statements:

_var1 = "xxx remove this portion xxx"
_var2 = SUBSTR(_var1, 5, 19)
ECHO _var2

display the following contents of _var2:

remove this portion

SUBSTR may be used in conditions. For example:

_len = 3
IF (SUBSTR(_var1,1,_len) = "xxx") GOTO @label

When the script runs, if begin is beyond the end of the string, a variable substitution error is given.

Copyright © 2017 American Chemical Society. All Rights Reserved.