Re: Modem query via AS?
Re: Modem query via AS?
- Subject: Re: Modem query via AS?
- From: Emmett Gray <email@hidden>
- Date: Tue, 24 Apr 2001 12:29:44 -0400
On Mon, 23 Apr 2001 02:48:01 -0400, Emmett Gray <email@hidden> wrote:
On Sun, 22 Apr 2001 21:12:19 -0700, SeaSoft Systems <email@hidden> wrote:
I want to query a modem connected to the modem port to see if it is
alive and well with Applescript.
In response to a private message I am adding substantial information
to my last post. Basically you can do anything you want to with a
modem using a HyperCard tell block from within AppleScript. The CTB
HyperCard Toolkit makes it possible and it is still available (though
_very_ hard to find, I'd say this is basically a secret link):
ftp://ftp.apple.com/developer/Tool_Chest/Development_Platforms/HyperCard_Related/APDA_HyperCard_Toolkits
Although very much unsupported, these externals work with OS 9.1 and
HyperCard 2.4.1.
In order to use the CTB Toolkit you must copy at least some of the
xcmds and xfcns from the stack "CTB Toolkit Example" included in the
download into a stack of your own. The only ones you need all begin
with "CTB". The home stack would be a fine place to put them,
otherwise you will have to tell HyperCard to go to the stack where
they are. Use a resource mover such as ResEdit, open the example
stack, and select, copy and paste the externals into your own stack.
At minimum, to run the example below, you need the following
(although you could just grab them all):
XCMDS:
CTBNewConnection
CTBConfigure
CTBOpen
CTBSendString
CTBClose
CTBDispose
The following are also useful (but not used in my script):
XCMD:
CTBChoose
XFCNS:
CTBConfiguration
CTBTool
The full CTB set has externals to control virtually every aspect of
the Comm Toolbox, but I haven't bothered with most of them as I am
just using them to dial the phone. The documentation is cryptic, the
example stack has bugs, but the XCMDS I have used have never given me
any trouble... once I figured out how to call them.
Once you have the externals installed you can call them from
AppleScript using a HyperCard tell block. Here is an AppleScript to
dial a number and hang up. Watch out for email word wrap: the line
beginning "CTBConfigure" is a single line all the way to the return
before the "--go off hook" comment line, and must not contain a
return character when compiled. I have used leading spaces on all
lines which are preceded by a return to make this clear. You can of
course change the values of any of the parameters as needed, but
don't change any ampersands, backslashes, quotes, returns, etc; this
is some unforgiving syntax here.
set dialNumber to "1-800-123-4567" -- whatever number to dial
set dialMode to "T" -- for tone dial, "P" for pulse
set modemScript to "
CTBNewConnection \"Serial Tool\"
CTBConfigure Baud && \"57600\" && DataBits && \"8\" && Parity &&
\"None\" && StopBits && \"1\" && Port && quote & \"Printer Port\" &
quote && Handshake && \"None\" && HoldConnection && \"False\"
--go off hook
--CTBOpen -- implicit in CTBSendString, so not required
CTBSendString \"ATH1\" & return
--wait 1 second for dial tone
wait 60
--dial the number
CTBSendString \"ATD" & dialMode & dialNumber & "\" & return
--wait 4 seconds while ringing
wait 240
--hang up
CTBSendString \"ATH0\" & return
CTBDispose
"
tell application "HyperCard"
go stack "DialStack" --where xcmds are, not needed if in Home stack
do script modemScript
end tell
Enjoy,
--Emmett