Error controlling dock w/ ui script

Hello, I am trying to write a script to control the dock and see if an item is checked and i keep getting the NSReceiverEvaluationScriptError: 4

any help would be appreciated, thanks

set SpeedLimitOn to false
set errors to {}

tell application "System Events"
	get system attribute "sysv"
	if result is greater than or equal to 4160 then -- 4160 is Mac OS X 10.4.0
		if UI elements enabled then
			tell process "Dock"
				tell list 1
					try
						set TDockItem to UI element "Transmission"
					on error
						tell current application to set errors to recordError("Transmission is not in the dock", errors)
						return
					end try
					tell TDockItem
						if value of attribute "AXIsApplicationRunning" is true then
							perform action "AXShowMenu"
							tell menu item "Speed Limit" of menu 1
								--display dialog value of attribute "AXMenuMarkChar" as Unicode text
								if (menu item "Speed Limit" of menu 1)'s (value of attribute "AXMenuMarkChar") is not (ASCII character 0) then --ERROR HERE
									set SpeedLimitOn to true
									tell current application to display dialog "woot" buttons {"OK"} default button "OK"
								else
									set SpeedLimitOn to false
									tell current application to display dialog "nope" buttons {"OK"} default button "OK"
								end if
								get SpeedLimitOn
							end tell
						else
							tell current application to set errors to recordError("This is an error", errors)
						end if
					end tell
				end tell
			end tell
		else
			
		end if
	else
		tell current application to display dialog "This script requires Mac OS X 10.4 Tiger or newer" buttons {"OK"} default button "OK"
	end if
end tell

to recordError(err, errArray)
	set theQuery to ""
	repeat with i in errArray
		set theQuery to theQuery & "///"
	end repeat
	set theQuery to split(theQuery, "///")
	return theQuery
end recordError

to split(fullitemcode, vdelimiter)
	set AppleScript's text item delimiters to vdelimiter
	set fullitemcode to fullitemcode's text items --turns foundtext into a list
	set AppleScript's text item delimiters to {""} --returns delimiter to apple's default
	return fullitemcode
end split




Hi,

some notes:
¢ the name of the attribute is “AXMenuItemMarkChar”
¢ you have a tell block tell menu item “Speed Limit” of menu 1, then refer to the same element can’t work
¢ coercing the value to a string (not Unicode text!) displays “3” if the item is checked

try this (I don’t use Transmission so I couldn’t test it in real life)


...
tell TDockItem
	if value of attribute "AXIsApplicationRunning" is true then
		perform action "AXShowMenu"
		delay 0.2 -- it's always safe to have a little delay till the menu will be shown
		tell menu item "Speed Limit" of menu 1
			--display dialog value of attribute "AXMenuItemMarkChar" as Unicode text
			if (get value of attribute "AXMenuItemMarkChar" as string) is "3" then --ERROR HERE
				set SpeedLimitOn to true
				tell current application to display dialog "woot" buttons {"OK"} default button "OK"
			else
				set SpeedLimitOn to false
				tell current application to display dialog "nope" buttons {"OK"} default button "OK"
			end if
			get SpeedLimitOn
		end tell
	else
		tell current application to set errors to recordError("This is an error", errors)
	end if
end tell
...