Trying to set the current value of a slider

I’m trying to use the contents of a combo box to set the current value of a slider with this script:

on selection changed theObject
	(*Add your script here.*)
	--set appearence to 0 if clan = nosferatu
	if (the contents of combo box "Clan" = "Nosferatu") then
		tell window "main"
			tell tab view "tab"
				tell tab view item "attributestab"
					set the contents of slider "char_app" to "0"
				end tell
			end tell
		end tell
	end if
end selection changed

when I test it out I get the error NSCannotCreateScriptCommandError (10)
I think the script is right and I don’t know were the problem is.

Thanks in advance

The main problem appears to be in this line…

It most likely should read something like…

if (the contents of theObject) = "Nosferatu" then

If you must reference it by name, you’re missing the references to the superviews above the combo box in the view hierarchy, so you’ll probably need something like…

if (the contents of combo box "Clan" of tab view item "attributestab" of tab view "tab" of window "main") = "Nosferatu" then

Other than that, it could be a bad reference to an object’s name in the view hierarchy, and unnamed object, or poor syntax (i.e. ‘contents’ vs. ‘content’).

Good luck,

Thank you for the help. Changing it to theObject got the script to work, but it doesn’t change the current value of the slider from 1 to zero.

Does anyone know how to do this?

Thanks in advance

Set it to 0 as an integer, not as a string:

set the contents of slider "char_app" to 0


I tried that and it didn’t seem to make a diffrence.

theObject and char_app are in diffrent tabs if that makes a diffrence

Is there something else that will work?


I’ve found that when scripting a control contained within a tab view item, that tab view item has to be visible (i.e., the current tab view item) for the control to recognize the command. Is the tab view item that contains the slider visible when you try to change its value? If not, make it so.

If this presents a problem for your app visually (annoying screen refreshes), then you can call the method “disableFlushWindow” of the window, change to the tab view item, change the slider value, change back to the previous tab view item, and call method “enableFlushWindow” of the window. Disabling the flush prevents the window from being redrawn so you can do some things without the user seeing what you’re actually doing.


I’m haveing two problems with this.

  1. when I use the if statement to see if theObject = “Nosferatu” then nothing happens. I know that everything is spelled right.

  2. if I take out the if statement then I can change to a diffrent tab but I still can’t set the current value of slider “char_app”. I get a NSReceiverEvaluationScriptError: 4 (1)

This is starting to drive me crazy. I hope someone has an idea.

Thanks in Advance

Are you evaluating the title of theObject, the contents of theObject, or the AS name of theObject? As mentioned above, you need to tell as Studio what to evaluate to test if it equals “Nosferatu”:

if name of theObject = "Nosferatu"


if contents of theObject = "Nosferatu"


This probably means you are referencing the slider wrong. If it is in a tab, you should try:

set contents of slider "char_app" to view of tab view item "attributestab" or tab view "tab" or window "main"

And, of course, make sure your controls are named exactly as you are referencing them. Naming a tab view can sometimes be tricky as when you click on it, it often times activates the tab view item, not the containing tab view.

If you continue to have problems, try posting your project files someplace where we can take a look at them and offer more assistance.


I was able to change to value of the slider but I am still having problems with the if statment.

here is the link to my project files.

I appreciate all of the help I have recieved so far.[/i]

In the future, if you post your stuff online, it’d be much easier if you zip it all into one file first and delete the build folder first to make it much smaller. Anyway, this works for me (even without having to change the current tab view item):


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thank you very much for all of your help with this. I was going nuts trying to figure it out.

I will remember to zip files up in the future.