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 variable to contain only numeric digits (e.g., 0 - 9).
Consider the following examples.
;; 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"
Windows environment variables can be set in the same way. Consider the following example where the sysdrive variable is set to the %SystemDrive% Windows environment variable.
SET sysdrive = %SystemDrive%
Related Command(s): DEC, INC, SETLEFT, SETRIGHT, SETLEN, SETMID, SETNUM See also: Script File Variable Arguments
|