1. I want to create a small addon that will notify me when someone has changed gear. Simple registration of unit_inventory_changed and when it fires, get the toons name and populate a fontstring on a frame. My question is as long as the frame is open does a variable stay populated or saved?



    if i have a variable peopleChangingGear and each time unit_inventory_changed fires I add that person's name to the variable. e.g.



    peopleChangingGear = peopleChangingGear .. newNiinjaName

    fontString:SetText(peopleChangingGear)



    How long does peopleChangingGear stay populated? forever? until the frame is closed? on UI reload?

    I want to create a small addon that will notify me when someone has changed gear. Simple registration of unit_inventory_changed and when it fires, get the toons name and populate a fontstring on a frame. My question is as long as the frame is open does a variable stay populated or saved?



    if i have a variable peopleChangingGear and each time unit_inventory_changed fires I add that person's name to the variable. e.g.



    peopleChangingGear = peopleChangingGear .. newNiinjaName

    fontString:SetText(peopleChangingGear)



    How long does peopleChangingGear stay populated? forever? until the frame is closed? on UI reload?

    I want to create a small addon that will notify me when someone has changed gear. Simple registration of unit_inventory_changed and when it fires, get the toons name and populate a fontstring on a frame. My question is as long as the frame is open does a variable stay populated or saved?



    if i have a variable peopleChangingGear and each time unit_inventory_changed fires I add that person's name to the variable. e.g.



    peopleChangingGear = peopleChangingGear .. newNiinjaName

    fontString:SetText(peopleChangingGear)



    How long does peopleChangingGear stay populated? forever? until the frame is closed? on UI reload?

    I can't really answer that question without seeing the code, and even then I don't think that will be useful.  If you create a table and store data into it then the data will remain in that table until the user interface is reloaded.  It doesn't have anything to do with the frame being open or closed, but if you re-set it at any point to some base value (like "") then it would appear to be reset.

    Im using an array in my addon and after the window is closed I want to clear the entire array. In the _Close() function i tried just putting "arrayName = {}" but apparently that does not clear the array. How do I clear an array, do i have to parse through each element?

    arrayName = {} leaves the original table intact, just changes the binding for the name 'arrayName' to a NEW table.  If you want to clear a table, you can do it manually with:

    for k,v in pairs(tbl) do

      tbl[k] = nil

    end

    Alternatively, you can call the Blizz defined function wipe() which does this for you, i.e. wipe(arrayName). 

    TY! wipe(arrayName) seems much simpliar than a loop, any drawbacks?

    Before i saw your post I actually used setglobal("arrayName", nil) is that not good practice or not doing what i think it is? I'll change ti wipe() but just curious.

    You should definitely not do it that way.  setglobal() and getglobal() really shouldn't be used.  You can just directly set it.