Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement

Regarding the statement added to this page that getglobal() checks children of objects as well, I've confirmed it to not be true within WoW (and given the nature of the function doesn't make much sense either). Please be more careful with these things. =) --NefariousN 05:45, 16 December 2007 (UTC)

_G[]

I just dumped the _G variable to a SavedVariables variable. Based on what I see in the 42MB SavedVariables file, getglobal(varname) === _G[varname] ("===" means identical in every way); therefore, any named frame in the global scope (with a name="" attribute (XML) or the 2nd argument in the CreateFrame() function is not nil) can be fetched from the top level of the _G table along with every single global (not explicitly declared local) variable.

Doing this will create two fields in the _G variable:

MyFrame = CreateFrame('Frame', 'MyFrameName')

Doing this in XML also adds the same two fields:

<Frame name="MyFrame">
    <Frame name="$parentName" />
</Frame>

They both add the following:

_G["MyFrame"] = {
    -- not sure how this works. Probably contains references to the inherited methods like :GetName(), :IsShown(), etc.
    [0] = userdata
}
_G["MyFrameName"] = {
    [0] = userdata
}

It doesn't matter what the parent is; the parent is merely a reference.

The first example adds two fields that each contain the same information (they are the same frame, after all) while the second example creates two fields that each contain different information (they are two different frames; one happens to be the parent of the other). Notice that the second example does not add a nested field to the _G variable (there is no _G["MyFrame"]["Name"] or _G["MyFrame"]["MyFrameName"] field).

Posted by: EGingell (T|C|F) on 07:04, 8 January 2008 (UTC)

Advertisement