Newbie needs help with a script....

Hi!
Can someone tell me why this doesn’t work?

tell application "iChat"
		if status of account "account name" is "avalible" then
			send "hello!" to account "account name"
		end if
		
	end tell

:shock:

//ThunderMac

I suggest something just a bit more involved. I don’t know how this would work in real application with iChat.

property watchedUser : "myself"
property message : "Hello!"
tell application "iChat"
	set theList to id of every account where status is available
	if theList contains watchedUser then
		sendChatMessageToUser(watchedUser)
	end if
end tell

on sendChatMessageToUser(userID)
	tell application "iChat"
		repeat with i in (every account where id is userID)
			send message to a
		end repeat
	end tell
end sendChatMessageToUser

It doesn’t work because (in addition to the fact you’ve typoed ‘available’) your query is comparing the wrong thing.

If you look at the dictionary for iChat you’ll see that ‘status’ is defined as:

	status away/offline/available  -- (inherited from the “application” class) My status on all services.

In other words, the status options are application constants called ‘away’, ‘offline’ and 'available. They are not strings.

Therefore you should:


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

Note the lack of quote marks around the ‘available’

Oh shit… Now I see that I’ve spelled available wrong… :oops:
Thank you guys!