WoW:API getglobal: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 35: Line 35:
   ...
   ...
  myvar = _G[globalName] -- this is what getglobal() does
  myvar = _G[globalName] -- this is what getglobal() does
Remark from Airlag:
getglobal() is doing a little more than _G[globalName]
It allso finds _G[anything][globalName] or _G[anything][deeper][globalName] or any deeper hidden child object.

Revision as of 17:21, 4 November 2006

WoW API < getglobal


Get a global variable, from a string.

getglobal("globalName")


Parameters

Arguments

("globalName")
globalName
String - Name of the global you want to get.

Returns

The object from the given string.

Details

This function is used to get an object if you generate the name of the object manually in your script:

i = some_dynamic_number;
local curFrame = getglobal("myFrame"..i)

You can immitate getglobal() by using the following script:

_G = getfenv()         -- set _G to the global environment once at the beginning of your script
 ...
myvar = _G[globalName] -- this is what getglobal() does

Remark from Airlag:

getglobal() is doing a little more than _G[globalName]

It allso finds _G[anything][globalName] or _G[anything][deeper][globalName] or any deeper hidden child object.