AppleScript chat client
AppleScript chat client
- Subject: AppleScript chat client
- From: Greg Strange <email@hidden>
- Date: Sun, 01 Apr 2001 17:54:16 -0500
Howdy all!
I have been playing around with a little toy for a few days now and I have
finally gotten to a point where I don't know what is wrong or what I don't
know.
I am writing an open-source applescript chat client. Nothing fancy so far
but I am using Dialog Director to get around the problem of no user
interaction with the remote machine. Or so I thought.
As it stands, I can send a message to a machine but cannot send one back to
the originating machine. It errors with no user interaction allowed. Can
someone take a look at the code I have written and see if there is something
I am missing, or try and reproduce it? Why would it let me send a message
one way but the receiving machine would not be able to send back?
My setup is OS 9.0 on an iMac DV and a PowerBook G3. No other osax are
used.
Your help on this would be greatly appreciated.
Here is the code in it's entirety.
property whoAmI : ""
global outFlag
set outFlag to false
if whoAmI is "" then
tell application "File Sharing"
set whoAmI to the owner name
display dialog whoAmI
end tell
end if
display dialog "Name of machine you want to send a message to?" default
answer ""
set theirMachine to the text returned of the result
display dialog "Text to send" default answer ""
set sendText to the text returned of the result
my sendThemText(whoAmI, theirMachine, sendText)
on updateText(whoSent, newText)
repeat
set chatWin to {size:{200, 200}, style:standard window,
closeable:true, name:"AppleScript Chat", default item:3, contents:{,
{class:static text, bounds:{5, 4, 93, 20}, contents:"Chat
Window:"}, ,
{class:text field, bounds:{8, 26, 191, 160}, value:newText}, ,
{class:push button, bounds:{101, 173, 171, 193}, name:"Send"}, ,
{class:push button, bounds:{16, 172, 86, 192}, name:"Cancel"}}}
dd install chatWin with fonts {name:"Charcoal", size:12} with
grayscale
set fleetWin to dd make dialog chatWin
repeat
set i to dd interact with user
if i = 4 then
set outFlag to true
exit repeat
else if i = 3 then
display dialog "Text to send back:" default answer ""
set sendText to the text returned of the result
my sendThemText(whoAmI, whoSent, sendText)
set outFlag to true
exit repeat
end if
end repeat
if outFlag is true then
exit repeat
end if
end repeat
end updateText
on sendThemText(whoAmI, theirMachine, sendText)
display dialog theirMachine & " " & whoAmI
if sendText is equal to "" then
display dialog "You have not typed anything in."
else
tell application "asChat" of machine theirMachine
updateText(whoAmI, sendText)
end tell
end if
end sendThemText
Watch the line breaks. It still has some display dialogs in there for
debugging purposes but you can see how it works easily enough. You have to
have program linking enabled on both machines. Just drop a copy on the
machines that want to talk and test. Thanks for the suggestions before
hand.
Greg Strange
--
I think I'll go home and lie very still,
feigning terminal illness.
Then the neighbours will all troop over to stare,
my love, perhaps, among them.
How she'll smile while the specialists
snarl in their teeth!
She perfectly well knows what ails me.
-Egyptian Love Poem