* dial.vt100 - Copyright 1989 by Starbound Computing, a division of
* Starbound Enterprizes.
*
* - Written by David W. Lowrey (USENET: amdahl!dwl10)
*
* THIS PROGRAM IS NOT IN THE PUBLIC DOMAIN!!!
*
* All Rights Reserved. This program may be freely used and copied, as long
* as no fee, other than a "reasonable" copying charge, is charged for
* it's use.
*
* Permission is granted to include this program in various user group PD
* collections, the FISH PD collection, or private PD collections.
*
* Inclusion in and commercial PD disk collections, including Magazine
* disks, requires written permission from the author.
*
* Any use for comercial purposes requires written permission
* from the author.
*
*/
/*
* Version 1.2: Striped off extra blanks from dial strings before sending
* them to VT100 (the modem).
*
* Version 1.1: Cleaned up code.
*
* Version 1.0: Initial public release
*/
/*
* default values
*
* feel free to change any of these
* Note that the default name must be exactly 25 characters long
*/
default.name = " "
default.phone = " "
default.baud = "2400"
default.parity = "NONE"
default.prefix = "ATDT"
default.postfix = "^M" /* carrage return after dial string */
default.script = " "
/*
* Make sure the required libraries have been loaded
*/
if ~show('l', "rexxarplib.library") then do
check = addlib('rexxarplib.library',0,-30,0)
if ~check then do
say "Can't load rexxarplib.library!"
exit -1
end
else nop
end
else nop
if ~show('l', "rexxsupport.library") then do
check = addlib('rexxsupport.library',0,-30,0)
if ~check then do
say "Can't load rexxsupport.library!"
exit -1
end
else nop
end
else nop
/*
* Create the window manager process
*/
address command run "rx 'call CreateHost(DIALWIN,DIALPORT)'"
address command "waitforport DIALWIN" /* wait for port to come active */
/*
* Window sizes
*/
window.leftedge = 50
window.topedge = 0
window.width = 470
window.height = 200
/*
* Initialize data values
*/
names. = default.name
phones. = default.phone
baud. = default.baud
parity. = default.parity
prefix. = default.prefix
postfix. = default.postfix
script. = default.script
savefile = "S:VT100.phones"
mod.=""
gadget.previous=0
modified=0
call OpenWin1
/* Open our host port */
call openport(DIALPORT)
/*
* read in the phone directory
*/
call ReadPhone
call DrawScreen1
/*
* Wait for messages at DIALPORT
*/
quitflag = 0
do forever until quitflag
call waitpkt(DIALPORT)
p = getpkt(DIALPORT)
if p ~== '0000 0000'x then
do
thisarg = getarg(p)
gadgetnum = getarg(p,1)
t=reply(p, 0)
/*
* Decode the IDCMP message
*/
select
/*
* Messages are either CLOSEWINDOW
*/
when thisarg == 'CLOSEWINDOW' then do
if modified=1 then reply=Request(140, 40,"NOTICE: There are unsaved\changes. Click 'Cancel' to abort.\Click 'Okay' to continue, and\loose all changes.",,"Okay","Cancel")
else reply="OKAY"
if reply == "OKAY" then do
call CloseWindow(DIALWIN)
quitflag = 1
end
else nop
end
/*
* ...or one of the Phone Number gadgets has been selected
*/
when thisarg == 'Gadget' then do
gadget.current = gadgetnum
if gadget.current == gadget.previous then do
call SetGadget(DIALWIN, gadget.current, "OFF")
gadget.previous=0
gadget.current=0
end
else do
call SetGadget(DIALWIN, gadget.current, "ON")
if gadget.previous ~== 0 then call SetGadget(DIALWIN, gadget.previous, OFF)
gadget.previous=gadget.current
end
end
/*
* ...or the LOAD Gadget has been selected
*/
when thisarg == 'Load' then do
if modified=1 then reply=Request(140, 40,"NOTICE: There are unsaved\changes. Click 'Cancel' to abort.\Click 'Okay' to continue, and\loose all changes.",,"Okay","Cancel")
else reply="OKAY"
if reply == "OKAY" then do
newsave=Request(140,40," LOAD PHONE FILE\\Enter name of phone file",savefile,"Okay","Cancel")
if newsave ~= "" then do
if exists(newsave) then do
savefile=newsave
call ReadPhone
call CloseWindow(DIALWIN,"CONTINUE")
call OpenWin1
call DrawScreen1
modified=0
end
else do
t=Request(140,40,"Phone file not found\Load request canceled",,"Okay",)
end
end
else nop
end
else nop
end
/*
* ...or the SAVE gadget has been selected
*/
when thisarg == 'Save' then do
newsave=Request(140,40," SAVE PHONE FILE\\Enter name of phone file",savefile,"Okay","Cancel")
if newsave ~= "" then do
savefile=newsave
call SavePhone
modified=0
end
else nop
end
/*
* ...or the DELETE gadget has been selected
*/
when thisarg == 'Delete' then do
if gadget.current ~= 0 then do
index=gadget.current
t=Request(140,40," DELETE ENTRY\\"names.index"\\is about to be deleted\Please confirm:",,"Okay","Cancel")
if t == "OKAY" then do
names.index=" "
phones.index=" "
baud.index="2400"
parity.index="NONE"
prefix.index=" "
postfix.index=" "
script.index=" "
call CloseWindow(DIALWIN,"CONTINUE")
call OpenWin1
call DrawScreen1
gadget.current=0
gadget.previous=0
modified=1
end
else nop
end
else nop
end
/*
* ...or MODIFY has been selected
*/
when thisarg == 'Modify' then do
if gadget.current ~= 0 then do
result=modify(gadget.current)
if result == 'Okay' then do
i = gadget.current
names.i = mod.names
phones.i = mod.phones
baud.i = mod.baud
parity.i = mod.parity
prefix.i = mod.prefix
postfix.i = mod.postfix
script.i = mod.script
modified = 1
end
else nop
call CloseWindow(DIALWIN,"CONTINUE")
call OpenWin1
call DrawScreen1
call SetGadget(DIALWIN,gadget.current, "ON")
end
else nop
end
/*
* ...or the Dial gadget
*/
when thisarg == 'Dial' then do
if gadget.current ~= 0 then do
if modified=1 then reply=Request(140, 40,"NOTICE: There are unsaved\changes. Click 'Cancel' to abort.\Click 'Okay' to continue, and\loose all changes.",,"Okay","Cancel")
call Text(DIALWIN, "You must press "RETURN" to save each field")
call ActivateGadget(DIALWIN, 1)
/*
* Wait for messages at DIALPORT
*/
quitflag = 0
gadnum.names = 1
gadnum.phones = 2
gadnum.baud = 3
gadnum.parity = 4
gadnum.prefix = 5
gadnum.postfix = 6
gadnum.script = 7
do forever until quitflag
call waitpkt(DIALPORT)
p = getpkt(DIALPORT)
if p ~== '0000 0000'x then
do
thisarg = getarg(p)
string = getarg(p,1)
t=reply(p, 0)
/*
* Decode the IDCMP message
*/
select
/*
* Messages are either CLOSEWINDOW ...
*/
when thisarg == 'CLOSEWINDOW' then do
if modified = 1 then reply=Request(140, 40,"NOTICE: There are unsaved\changes. Click 'Cancel' to abort.\Click 'Okay' to continue, and\loose all changes.",,"Okay","Cancel")
else reply="OKAY"
if reply == "OKAY" then do
ret="Not Modified"
quitflag = 1
end
else nop
end
/*
* ...or "Quit" (exit with new values)
*/
when thisarg == 'Okay' then do
if modified == 1 then do
call formatmod
mod.names=center(strip(mod.names),25)
ret = 'Okay'
end
else ret = 'Not Modified'
quitflag = 1
end
/*
* ...or one of the free formstring gadgets has been selected
*/
when thisarg=='names' | thisarg=='phones' | thisarg=='prefix' ,
| thisarg=='postfix' | thisarg=='script' then do
upperarg=upper(thisarg)
if mod.upperarg ~= string then do
mod.upperarg = string
modified = 1
end
else nop
nextgad = gadnum.upperarg + 1
if nextgad == 8 then nextgad = 1
else nop
call ActivateGadget(DIALWIN, nextgad)
end
/*
* ...or baud has been selected
*/
when thisarg == 'baud' then do
if string=300 | string=1200 | string=2400 | string=4800 | string=9600 then do
mod.baud = string
modified = 1
call ActivateGadget(DIALWIN, gadnum.baud+1)
end
else do
r=Request(140, 40, "Invalid Baud rate. Baud rate must be\one of the following:\300, 1200, 2400, 4800, 9600",,"Okay")
call ActivateGadget(DIALWIN, gadnum.baud)
end
end
/*
* ...or Parity has been selected
*/
when thisarg == 'parity' then do
string = upper(string)
if string='NONE' | string='MARK' | string='SPACE' | string='EVEN' | string='ODD' then do
mod.parity = string
modified = 1
call ActivateGadget(DIALWIN, gadnum.parity+1)
end
else do
r=Request(140, 40, "Invalid Parity. Parity must be\one of the following:\NONE, MARK, SPACE, EVEN, ODD",,"Okay")