SET Assign or concatenate string variable(s) |
Top Previous Next |
This script command assigns a string value to a variable or concatenates up to four strings and assigns the resulting string to a variable. The SET command differs from the SETNUM command in that SETNUM limits the value to contain only numeric digits (e.g., 0 - 9).
Important Using the SET command with only the [ variable ] argument and no values will cause that variable to be unassigned. Using the SET command by itself with no arguments unassigns all current user-defined script variables but does not reset the values of internal variables.
Here are a few ways the SET command may be used:
;; assign a string to a variable SET new_string = "this is a new string"
;; assign a previously assigned variable to a variable SET another_string = new_string
;; concatenate two strings SET helloworld = "hello " & "world"
;; concatenate four variables SET var1 = "Robo-FTP " SET var2 = "is " SET var3 = "the " SET var4 = "greatest." SET truth = var1 & var2 & var3 & var4
;; concatenate two strings (alternate syntax) SET hello_world = "hello " SET hello_world &= "world"
Consider the following example where the sysdrive user-defined script variable is set to the %SystemDrive% Windows environment variable.
SET sysdrive = %SystemDrive%
Note: Windows environment variables cannot be modified directly.
Related Command(s): SETLEFT, SETRIGHT, SETMID, SETLEN, SETEXTRACT, SETSUBSTR, SETNUM, DEC, INC See also: Script File Variables |