Assign
给变量赋值.
Assign ( "varname", "data" [, flag = 0] )
参数
varname
|
需要赋值的变量名. 不能是数组元素, 并且必须只包含字母,数字和下划线字符(依照正常的变量命名约定)
|
data
|
赋予变量名的数据值.
|
flag
|
[可选] 变量的赋值方式(可将所需选项的对应值相加):
$ASSIGN_CREATE (0) = (默认) 如果需要则创建变量
$ASSIGN_FORCELOCAL (1) = 强制变量创建为局部作用域
$ASSIGN_FORCEGLOBAL (2) = 强制变量创建为全局作用域
$ASSIGN_EXISTFAIL (4) = 如果变量不存在则忽略
常量定义在 AutoItConstants.au3
|
返回值
成功:
|
返回 1.
|
失败:
|
返回 0, 无法创建或赋值指定的变量.
|
备注
如果有需要, 使用 Assign() 创建或写入一个变量, 然后使用 Eval() 函数读取该变量, 并使用 IsDeclared() 函数检查该变量是否存在.
函数示例
#include <MsgBoxConstants.au3>
; 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)
----------------------------------------
该函数可以通过命令 exect 调用
参见:
Eval, IsDeclared, Execute
exect=Assign('var_s','Hello',2)||_ViewValues('$var_s') ;; 将数据分配给具有指定名称的变量的示例
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|