Показать полную графическую версию : [решено] Возможно ли вызвать глобальную переменную в функции
Можно ли вызвать глобальную переменную в функции путем собирания ее имени из других переменных?)
Пример:
global $Name
Func _test ($ame)
$N'ame' = ....
Endfucn
как-то так...
Такое возможно?
Пример »
Куски кода следует заключать в тег [code].
Такое возможно? »
Да:
Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $Name
_test("ame")
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _test($ame)
Assign (http://www.autoitscript.com/autoit3/docs/functions/Assign.htm)("N" & $ame, "Data", 2)
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)($Name & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)
madmasles
13-01-2012, 19:06
HFShak,
Или наоборот.Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $Name = 'Data'
_Test('ame')
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _Test($ame)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $s_Data = Eval (http://www.autoitscript.com/autoit3/docs/functions/Eval.htm)('N' & $ame)
ConsoleWrite (http://www.autoitscript.com/autoit3/docs/functions/ConsoleWrite.htm)($s_Data & @LF (http://www.autoitscript.com/autoit3/docs/macros.htm#@lf))
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.