API getglobal

From Wowpedia
Jump to: navigation, search
"I" iconThis function is implemented by FrameXML in FrameXML/UIParent.lua.

Returns the value of a global variable by name (or key). Deprecated, use the global table _G instead:

value = getglobal(globalKey)        --getglobal deprecated
value = _G[globalKey]               --new syntax to get a global

Arguments

globalKey 
Any - "Name" of the global you want to get.

Returns

value 
Any - The value of the specified global variable.

Details

Accesing globals by name may be useful when dealing with arrays of widgets:

for i=1, 10 do
 local curFrame = _G["MyAwesomeFrame" .. i]
 -- do something with curFrame, like position it:
 curFrame:SetPoint("TOP", 0, -20*i)
end