Function Reference


Eval

Return the value of the variable defined by a string.

Eval ( string )

Parameters

string string representing name of the variable.

Return Value

Success: the value of the variable.
Failure: "" (empty string) and sets the @error flag to non-zero.

Remarks

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

Related

IsDeclared, Assign, Execute

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign the variable string sString with data.
    Assign("sString", "This is a string which is declared using the function Assign")

    ; Find the value of the variable string sString and assign to the variable $sEvalString.
    Local $sEvalString = Eval("sString")

    ; Display the value of $sEvalString. This should be the same value as $sString.
    MsgBox($MB_SYSTEMMODAL, "", $sEvalString)
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Initialize the variale $sString with data
    Local $sString = "This is a string"
    #forceref $sString

    ; Find the value of the variable string sString and assign to the variable $sEvalString.
    Local $sEvalString = Eval("sString")

    ; Display the value of $sEvalString. This should be the same value as $sString.
    MsgBox($MB_SYSTEMMODAL, "", $sEvalString)
EndFunc   ;==>Example