This error jumps usually when, effectively, “myVar” hasn’t been defined. You may check your window’s project and make sure the object you are referring IS a text field (not, eg, a text view into a scroll view), the object IS WHITHIN the window “Main” (not, eg, into a tab view or a group box, whithin window “main”), object names ARE “Blerf” and “Main”… And such stuff, which usually takes most of the time when developing in ASS :x
Make sure you’re comparing apples to oranges, so to speak.
In your first example above, you wouldn’t likely be able to use a ‘>’ operand in your conditional statement if said text field doesn’t yet have anything in it.
And even if it does, it would need to be a number of some kind to be able to do a greater-than conditional, no?
Also, let me take this opportunity to reiterate OBJECT HIERARCHY.
Be sure your object tree is correct. ie.:
If the text field is WITHIN a tab view item, within a tab view, within a window, it is imperitive that all of those objects be represented in your statement like so:
set myVar to text field "foo" of tab view item "bar" of tab view "kung" of window "fu"
And, as JJ said, make sure you’re talking to a text field and not some other type of text-container.
Post again with more complete code if you need further help. I’m sure we can figure it out and get you on your way.
I have just confirmed that I am using a text field (NSTextField). I have a number formatter attached to it, so it does return a number.
I have created a basic window. I am not using any tabs. I have learned the hard way about “the reference to the reference to the reference, etc., etc.” in applescript. In the beginning (about 5-6 years ago), that slowed me down more than anything. I KNEW what I was referring to, why didn’t the computer?
When the text field was empty the contents show up as “missing value”, however, the another property, double value returned 0.0 (as a number). Instead of pulling the contents, I will now pull the double value. Works for an empty text field as well as a text field with info. Next step, confirm that the formatter handles alpha character input properly (i.e. not allow it–I need dollor amounts in this field).
Thanks for all the help and suggestions,
Brad Bumgarner, CTA