SET        Assign or concatenate string variable(s)

Top  Previous  Next

Syntax:

SET

[ variable ]  =  [ value ] [ & value2 ] [ &  value3 ] [ &  value4 ]

Alt Syntax:

SET

[ variable ] [ &= value ]

Arguments:

[ variable ]

Variable to assign; if the variable does not previously exist it is created.

 

[ value ]

Variable or string defining the value to assign to [ variable ] or the first concatenation string when followed with the concatenation operator.

 

&

The catenation operator; + is also recognized.

 

[ value2 ]

Variable or string defining the optional second string to concatenate to [ value ] with result stored in [ variable ].

 

[ value3 ]

Variable or string defining the optional third string to concatenate to [ value ] & [ value2 ] with result stored in [ variable ].

 

[ value4 ]

Variable or string defining the optional fourth string to concatenate to [ value ] & [ value2 ] & [ value3 ] with result stored in [ variable ].

 

[ &= value ]

Variable or string value to concatenate to [ variable ] with result stored in [ variable ] when the alternate concatenation syntax is used.

Options:

none

 

 

 

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.
Note: Windows environment variables cannot be modified directly.

 

SET sysdrive = %SystemDrive%

 

Related Command(s): DEC, INC, SETLEFT, SETRIGHT, SETLEN, SETMID, SETNUM

See also: Script File Variable Arguments