# Function Reference

Assign

Assigns a variable by name with the data.

Assign ( "varname", "data" [, flag] )

Parameters

varname | The name of the variable you wish to assign.
data | The data you wish to assign to the variable.
flag | [optional] controls the way that variables are assigned (add required options together): 0 = (default) Create variable if required 1 = Force creation in local scope 2 = Force creation in global scope 4 = Fail if variable does not already exist

Return Value

Success: | Returns 1.
Failure: | Returns 0 if unable to create/assign the variable.

Remarks

If there is a need to use Assign() to create/write to a variable, then in most situations, Eval() should be used to read the variable and IsDeclared() should be used to check that the variable exists.

Related

Eval, IsDeclared

Example

Global $variable
If Assign("variable", "Hello") Then MsgBox(4096, "", $variable) ; Will print "Hello"