Assign

Reference:        Alphabetical Command List 

                        Topical Command List

Open Syntax Window

MoveNameValue

The Assign command acts to both declare a variable and set its value.  Variables must be assigned before they can be used.  Once assigned, the variable value is referenced much like a wildcard value.  A single percent (%) acts as the escape character, and the name is included within single quotes.  For example, the variable count would be referenced with %’count’.  This allows variables to appear anywhere within a file name or a string.  The type of a variable is implicitly determined by the type of the value being assigned.  The three types are string, numeric, and Boolean

String values always begin and end with double-quotes and may include other string variables and/or wildcard values.  The quotes are required even when one string variable is being assigned to another.  This rule eliminates the need for concatenation operators.  For example, the following command builds a new string from two existing variables:

            :Assign: FullName = “%’Prefix’.%’Suffix’”

Prefix and Suffix are combined with the period and result in the value given to FullName.

String assignments can also include a number of parsing operators.  These are the file parsing functions such as GetPath and GetFile, and the string operators such as Left, Right, and Mid.  Only one operator is allowed in each assignment.  The output of these operations is always a string.  Finally, the description associated with an error value, if any, may be returned as a string from the Error function.

Numeric values may include only numeric constants or previously declared numeric variables.  Addition and subtraction are the only supported mathematical operations.  Parentheses may not be used to establish precedence, since it is unnecessary without additional operations such as multiplication or division.  Numeric assignments also support the Date function, which facilitates the manipulation of dates and times and the retrieval of a file’s last modified date.

Boolean assignments include the constants true and false, the Present operator that checks for the presence of a specified file, and conditional expressions

A special naming convention is used to distinguish names assigned within the Each_Server scope if an IF/End_IF command.  The Each_Server scope declaration allows the script to process subsequent commands at different times for each server name.  Variables assigned within such a block must be able to take on values associated with each server being processed.  Beyond FTP identifies such variables by the prefix “SV.  The above assignment within an Each_Server block would be:

            :Assign: SV.FullName = “%’Prefix’.%’SV.Suffix’”

Note that variables of both types may be read in any context.  It is only the variable being assigned that depends on the scope.  SV.  variables may only be assigned within an Each_Server block.  Non-SV. variables may only be assigned within an All-Servers block.