Checking whether variable changed

I’ve got a question for all of you out there that know applescript better than me. Is there any way to see if a variable has been assigned a value yet? Basically, my plan right now is to set a variable to the result of a function. The function will only return something when it finds the value that needs to be stored in the variable. So, I want to know if there’s a way to see if something was assigned to the variable. Sorry if this is kind of confusing, but it’s pretty much like checking to see if an object is null in Java or C. Any help or info would be great. Thanks.

Would it work to initialize the variable with a known value and then check to see if the value has been changed by the function?

set foo to ""
-- your function
if foo is "" then
	-- no change made by the function
	-- function changed the value
end if

– Rob

yeah, that looks like a pretty good idea, although I’ve found another approach that will work better. Just for future reference, do you know if there is way to see if a variable has a value, or do you just pretty much need to check for the value you set yourself previously(as you did in your example)? Thanks.

You might use something like this.

set var to my return_nothing()

	class of var
on error err number errNum
	if errNum is -2753 then display dialog err
end try

to return_nothing()
end return_nothing

– Rob