Noob Question:setting enabled of a popup based on the value of switch

Hi all.

i am trying to get a switch to enable/disable a popup button when on/off and i have run into a problem. i originaly tried to do this with a normal if statement but it was enabling then disabling the popup button every time i clicked instead of doing one or the other. I decided that i need to put in an else into my if statement but i can’t get it to work… Can someone please show me how to write this? below is my attempt. thanks in advance…

on clicked

on DoThisMainThing
Set ThisIsTrue to enabled of popup button “assignPB” of box “Assign” of window “pmate” is true
set ThisOtherThingIsTrue enabled of popup button “assignPB” of box “Assign” of window “pmate” is false
set dothis to set EnabledState to true
set dothisotherthing to set EnabledState to false
if ThisIsTrue then
dothis
else if thisOtherhingistrue then
DoThisOtherThing
end if
end DoThisMainThing

if theObject is button “AssignSwitch” of box “Assign” of window “pmate” then
DoThisMainThing
end if

end clicked

PS is there an easier way to do this through Interface builder?

One of my projects, iPhotos By Size, performs a similar thing. When a checkbox is checked, the date fields are enabled, the default state is that the date field is unavailable. Here is the code that I use:

on clicked theObject
	set butt to theObject's name
	if butt = "use_dates" then --This button toggles the date fields from active to inactive
		if date_State is false then --if they are already inactive, they need to be activated.......
			tell window "main"
				set enabled of control "from_date" to true
				set enabled of control "to_date" to true
			end tell
			set date_State to true --....and this variable needs to be set to true
		else
			tell window "main" --This will only kick in if the date_State variable is true, meaning that the user wishes to turn them off
				set enabled of control "from_date" to false
				set enabled of control "to_date" to false
			end tell
			set date_State to false --So, now, the variable is set back to false.
		end if

The variable date_State is defined at the beginning as a property:

property date_State : false --Starting up, the date controls need to be inactive

I hope this helps.