Can I Bind an InterfaceBuilder object to a variable in a script?

Hi!

Is there a way to bind an object in InterfaceBuilder to a variable in a script?
So that changing the value of the variable, automatically updates the content of the object?
And when the user changes the content of an object (lets say a text field) the variable automatically gets the new value?

So that instead of

on clicked theObject
	if name of theObject is "myIncrementButton" then
		set content of text field "myNumber" of window "main" to ((content of text field "myNumber" of window "main") + 1)
	end if
end clicked

i could just write

on clicked theObject
	if name of theObject is "myIncrementButton" then
		set myNumber to myNumber + 1
	end if
end clicked

thanks, Mike

Depending on what you’re doing, you may want to look into. Bindings. I’d start with this thread: Binding Your Preferences in AppleScript Studio

Also, if you’re using an NSStepper control and a text field, and you want the stepper to change the text field, then you can use connections inside IB.

Finally, you could shorten the code you currently have:

tell text field "myNumber" of window "main" to set content to content + 1