I’ve been working on an iChat remote program in Code Exchange here. All of my systems are set up the same. So relative paths are not an issue when testing on my machines. When I post the code here… It gets messed up for people. When compiled the script retains my systems paths. Also for some reason my lists aren’t separating correctily when ran through iChat, in the Script Editor they are fine (Error filtering commands. Can’t make file {missing value, “time.scpt”} into type file. -1700)
property scriptLoc : missing value
property weatherLoc : missing value
property loadCommand : missing value
--property theCommands : missing value
property theCommands : {{"time", "time.scpt"}, {"externalIP", "external IP.scpt"}, {"process", "process.scpt"}, {"email", "email.scpt"}, {"Google", "Google.scpt"}, {"help", "help.scpt"}, {"iTunes", "iTunes.scpt"}, {"say", "say.scpt"}, {"volume", "volume.scpt"}, {"weather", "weather.scpt"}, {"Wiki", "Wiki.scpt"}, {"activate", "activate.scpt"}, {"echo", "echo.scpt"}, {"kill", "kill.scpt"}, {"send", "send.scpt"}, {"TinyURL", "TinyURL.scpt"}, {"uptime", "uptime.scpt"}, {"credits", "credits.scpt"}, {"internalIP", "internal IP.scpt"}}
on run
set scriptLoc to ((path to home folder as text) & "Documents:AAIR:")
set weatherLoc to POSIX path of scriptLoc & "weather.py"
display dialog "Command to test: " default answer ""
set theMessage to the text returned of the result
set theResponse to load(theMessage)
display dialog theResponse
end run
on load(theMessage)
set loadCommand to ""
------------------------
try
set staticCommand to text 1 thru ((offset of " " in theMessage) - 1) of theMessage
set dynamicCommand to text ((offset of " " in theMessage) + 1) thru -1 of theMessage
set theResponse to ""
on error error_message number error_number
set theResponse to "Error splitting commands. " & error_message & " " & error_number
return theResponse
end try
------------------------
try
repeat with t in theCommands
------------------------
try
set CCommand to item 1 of t
if staticCommand = CCommand then
set cScript to item 2 of t
set loadCommand to load script file (scriptLoc & cScript)
exit repeat
end if
on error error_message number error_number
set theResponse to "Error filtering commands. " & error_message & " " & error_number
return theResponse
end try
end repeat
------------------------
try
if loadCommand is "" then
set theResponse to "Invalid Command"
else
set theResponse to loadCommand's AAIR(theMessage, staticCommand, dynamicCommand, weatherLoc)
end if
on error error_message number error_number
set theResponse to "Error loading plugin. " & error_message & " " & error_number
return theResponse
end try
------------------------
--end repeat
on error error_message number error_number
set theResponse to "Error loading. " & error_message & " " & error_number
return theResponse
end try
return theResponse
end load
using terms from application "iChat"
on message received theMessage from theBudy for theChat
try
set theResponse to load(theMessage)
send theResponse to theChat
on error error_message
send error_message to theChat
end try
end message received
end using terms from