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 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