AppleScript Help

Discussion in 'Mac Apps and Mac App Store' started by ezkimo, Sep 25, 2004.

  1. ezkimo macrumors regular

    Joined:
    Sep 12, 2002
    #1
    Hellooo,
    So, I am trying to make an AppleScript that sends a message to userA when userB signs on. Since I am new to AppleScript, problems popped up pretty quickly.

    Heres what I got:

    Since I want it hardwired to a specific configuration of people I can just change out the "userA" and "userB" for their actual screennames.

    When I run the script it waits till userA has come online then says it cant continue to go (the send message part of the script)...any ideas?

    Thanks!

    Edit: To test it out I have been using the bots "Smarterchild" and "Infocombot" as the users if that helps
     
  2. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #2
    The problem seems to be something to do with nested "tell application "iChat"" blocks (since go is already in one when it's called). The following code appears to solve it. By the way, what are you using watchedUser for? Currently it isn't ever used except to parse it to go, which also doesn't use it.

    Code:
    property watchedUser : ""
    on idle
    	tell application "iChat" to set isAvailable to (status of account "userA" is available)
    	if isAvailable then
    		go(watchedUser)
    		quit
    	end if
    	return 10
    end idle
    
    on go(watchedUser)
    	set message to "online!"
    	tell application "iChat"
    		send message to account "userB"
    	end tell
    end go
     
  3. ezkimo thread starter macrumors regular

    Joined:
    Sep 12, 2002
    #3
    I took a script for a completely different thing and modified it to come up with what I had. That script had the watched user thing and for some odd reason I was getting even less success without it...so I left it...AppleScript Newbie..

    Thanks so much!
     
  4. ezkimo thread starter macrumors regular

    Joined:
    Sep 12, 2002
    #4
    Actually, turns out that it dosnt work..I get a "NSRecieverEvaluationScriptError: 4" hmmmmmmmm
     
  5. HexMonkey Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #5
    I got that error when I was first testing the script. From what I could tell, you get it if userA isn't on your buddy list and you're not having a chat with them. You also get a different error if userB isn't on your buddy list or isn't online when sending the message to them. So to fix the error, just make sure that userA is on your buddy list.
     

Share This Page