0

script error: Can’t make application into type application. (-1700) Bad parameter data was detected or there was a failure while performing a coercion. (Line 17, Character 28). I think it may be a problem with my dialog popup or script the line below.

using terms from application 'Messages'
  on message sent theMessage with eventDescription
    display dialog (eventDescription)
  end message sent

  on message received theText from theBuddy with eventDescription
  end message received

  on chat room message received theText with eventDescription from theBuddy for theChat
    set getname to name of theBuddy as text
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 
    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  end chat room message received

  on active chat message received theText with eventDescription from theBuddy for theChat
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 

    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  end active chat message received

  on addressed message received theText with eventDescription from theBuddy for theChat
    set getname to name of theBuddy as text
    try 
      set myresult to get id of theBuddy
    on error errMsg
      set errMsgParts to splitText(errMsg, "\"")
      set errCount to count of errMsgParts
      set myresult to item (errCount - 1) of errMsgParts
    end try 
    display dialog ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
    do shell script ("/Home/Peter/repos/imessage/message '" & theText & getname & myresult & "'")
  end addressed message received

  on received text invitation with eventDescription
  end received text invitation

  on received audio invitation theText from theBuddy for theChat with eventDescription
  end received audio invitation

  on received video invitation theText from theBuddy for theChat with eventDescription
  end received video invitation

  on buddy authorization requested with eventDescription
  end buddy authorization requested

  on addressed chat room message received with eventDescription
  end addressed chat room message received

  on login finished with eventDescription
  end login finished

  on logout finished with eventDescription
  end logout finished

  on buddy became available with eventDescription
  end buddy became available

  on buddy became unavailable with eventDescription
  end buddy became unavailable

  on received file transfer invitation theFileTransfer with eventDescription
  end received file transfer invitation

  on av chat started with eventDescription
  end av chat started

  on av chat ended with eventDescription
  end av chat ended

  on completed file transfer with eventDescription
  end completed file transfer

end using terms from
user7903682
  • 199
  • 1
  • 1
  • 18
  • your "do shell script" is supposed to run shell instruction. and /home/Peter/repors/imessage/message... is certainly not a valid instruction ! – pbell Jul 05 '17 at 05:20
  • Well, it's a command.... It just has the full path – user7903682 Jul 05 '17 at 13:29
  • but if theText contains spaces, then the shell may see spaces as separators (the ' is not always interpreted correctly). if you type exactly the same text on Terminal what is the result ? (same text means same spaces, same ' – pbell Jul 05 '17 at 18:05
  • Well it should be like *myprogram "text"* and I'm trying to display a dialog of what it would look like, but it errors out – user7903682 Jul 05 '17 at 20:19
  • first try to display dialog with "(class of myresult) as string". I assume theText and get name are text as expected. so myresult could be the root cause. – pbell Jul 06 '17 at 05:41
  • still no luck. It gives me the same error. The line I have is `display dialog ((class of myresult) as string)` – user7903682 Jul 06 '17 at 13:43
  • In fact, it might be this line `set errMsgParts to splitText(errMsg, "\"")` – user7903682 Jul 06 '17 at 15:02
  • it looks that myresult is just not defined (if you can't get its class). this is probably why you are jumping in the on error part. Try "set myresult to id of theBuddy". add a log just after to see if the script jumps to on error just after the "set myresult" or not. – pbell Jul 06 '17 at 16:29

1 Answers1

1

I simply changed 'Messages' to "Messages" and that allowed me to compile, perhaps this will help you.

Change the first line from:

using terms from application 'Messages'

To:

using terms from application "Messages"

Hope this helps!

YeaTheMans
  • 1,005
  • 8
  • 19