How can I enable/disable buttons in my interface with a script?

How can I enable/disable buttons in my interface with a script. Say, for example the button’s name is “WeeklyMainenance” The buttons are in tabs, if that’s an issue.

You might have to tweak the reference to the button itself depending on whether your have multiple tab views (this assumes the tab view is the first one), which tab of the tab view you want to target (this is currently targeting the first tab), and whether this is in the main window or not. The flag to enable or disable the button is up to you but this code will enable it only if it is currently Sunday:

set the_button to button "WeeklyMainenance" of view of tab view item 1 of tab view 1 of window "main"
if day of (current date) = 1 then --Sunday 
	set enabled of the_button to true
else
	set enabled of the_button to false
end if

Jon