Thread Tools Display Modes
01-30-12, 09:56 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
a means of checking if a frame exists

is there a means to check if a frame exists not just if it is shown or visible?

if you put an or inside of a setpoint say...
frame:SetPoint("LEFT", otherframe, "LEFT", or "LEFT", someotherframe, "LEFT") would it skip passed the first if it could not find that frame?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-30-12, 10:06 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
frame:SetPoint("LEFT", otherframe or someotherframe, "LEFT")
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-30-12, 10:12 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Does that work for doing SetParent(something or somethingelse) ? as far as i can tell it does not
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-30-12 at 10:21 PM.
  Reply With Quote
01-30-12, 10:42 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If, for some reason, it's not working, then do this:

local frame = something or somethingelse
SetParent(frame)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
01-31-12, 11:29 AM   #5
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
I'm pretty sure you can do something along the lines of:

Code:
if frameName then
-- Code to be executed if it exists
end
If I'm not mistaken

If that does nothing you could just to the nil check

Code:
if (frameName~=nil) then
-- Code to be executed if it exists
end
  Reply With Quote
01-31-12, 11:31 AM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Waky View Post
I'm pretty sure you can do something along the lines of:

Code:
if frameName then
-- Code to be executed if it exists
end
If I'm not mistaken

If that does nothing you could just to the nil check

Code:
if (frameName~=nil) then
-- Code to be executed if it exists
end
The first method i know does not work... that only works for addon names. You could do a check to see if an addon is loaded via if name then but does not work for frames that do not exist. Ill try the if framename == nil then do such and such or vice verse ~=

Last night i already went with a method not listed here at all... since what im trying to do is run my UI with files missing and i want to have one file in the UI check to see if frames from the other file are available and run them if they are or dont if they are not. What i ended up doing is just having the file create a variable when it loads and have the other file check for the variable. Most likely not an efficient method and if i can get either of the above to work im going to do that.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-31-12 at 11:34 AM.
  Reply With Quote
01-31-12, 01:45 PM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Seerah View Post
If, for some reason, it's not working, then do this:

local frame = something or somethingelse
SetParent(frame)
Neither of the or'ing methods work it always trys to hook to the first frame passed and when it finds its not a frame it errors.

doing a frame =~ nil did work
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-31-12 at 01:53 PM.
  Reply With Quote
01-31-12, 02:28 PM   #8
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Originally Posted by Grimsin View Post
Neither of the or'ing methods work it always trys to hook to the first frame passed and when it finds its not a frame it errors.

doing a frame =~ nil did work
Did you put ~= or =~?
  Reply With Quote
01-31-12, 05:24 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Grimsin View Post
Neither of the or'ing methods work it always trys to hook to the first frame passed and when it finds its not a frame it errors.

doing a frame =~ nil did work
Then you asked the wrong question. You asked if a frame had been created yet. If a frame has not been created, then it is nil - assuming that you used a unique name or unique global variable for it. If it is nil, then my line will pass through the or. If, as you say, it throws an error saying that it's not a table, then it's not nil. It's equal to something else. Meaning that you are using the same variable name for multiple things.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » a means of checking if a frame exists


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off