home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
427.lha
/
VLTautodialer_v.7BETA
/
autodial.vlt
< prev
next >
Wrap
Text File
|
1990-10-07
|
8KB
|
253 lines
/* Autodialer for VLT */
/* Beta v .7. Don't say I didn't warn you.... */
/* This program is copyright 1990, Dan Sugalski. */
/* The archive it appears in may be freely redistributed */
/* provided that it remains intact */
address vlt
if ~show(l,"rexxsupport.library")
then call addlib('rexxsupport.library',0,-30,0)
if ~show(l,'rexxarplib.library')
then call addlib('rexxarplib.library',0,-30,0)
if ~open(phone,'S:VLTPhone',r)
then do
message "{Can't open phone file!}"
exit 1
end
do i=1 while ~eof(phone)
line = readln(phone)
parse var line phone.name.i phone.number.i phone.macro.i phone.parity.i phone.strip.i
end
call close(phone)
screen = 'VLT'
height=ScreenRows(VLT) /* get screen size for VLT */
width =ScreenCols(VLT) /* screen. */
if height = -1 then do /* a -1 means that the screen */
height = ScreenRows() /* we tried to get data for */
width = ScreenCols() /* doesn't exist. So we get */
screen = '' /* workbench values */
rx '{call createhost(DIALPORT, DIALPORT2)}' /* open port on workbench */
end
else
rx '{call createhost(DIALPORT, DIALPORT2, VLT)}' /* open port on VLT screen */
call openport(dialport2) /* open our port */
do j=1 to 10 while ~showlist(P,dialport) /* wait for opening of host */
call delay(10)
end
if ~showlist(p,dialport) /* if no host, abort with a */
then do /* message. */
message '{ERROR in CreateHost!}'
exit 1
end
do until phone.name.i ~= "" /* strip out trailing blanks */
i = i-1
end
do j=1 to i /* here we make all the names */
if length(phone.name.j) < 15 /* fiftee n characters long. We */
then phone.name.j = center(phone.name.j, 15) /* either center and pad with */
else phone.name.j = left(phone.name.j, 15) /* spaces or we truncate. */
end
min = 1 /* initial settings */
max = 10
if max > i then max = i
/* we open the window and show the first page of gadgets. */
call openwindow(dialport, 10, 10, 300, 180, "CLOSEWINDOW+GADGETUP", "WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH", "VLT Autodialer")
call dogadgets(min, max, i)
/* This loop upcoming is our major port watcher. It gets the messages */
/* from user gadget picks and processes them. */
do dummy1 = 1
do dummy2 = 1
token = getpkt(dialport2)
if token = '0000 0000'x then leave
myarg = getarg(token)
call reply(token)
select
when myarg = 'DOWN' then do /* Change pages */
call cleargadgets(min, max)
max = max + 10
if max > i then max = i
min = max - 9
call dogadgets(min, max, i)
end
when myarg = 'UP' then do /* Change Pages */
call cleargadgets(min, max)
min = min - 10
if min < 1 then min = 1
max = min + 9
call dogadgets(min, max, i)
end
otherwise leave dummy1
end
end
call waitpkt(dialport2)
end
if myarg = 'CLOSEWINDOW' then do /* If closewindow, must be an abort */
call closewindow(dialport)
exit 0
end
/* At this point we must have been given a */
/* phone number gadget. So we get the info */
/* and process it properly. */
call closewindow(dialport, continue)
if phone.parity.myarg ~= '' then do
parity phone.parity.myarg /* set parity to specified */
end
else do
parity '8N1' /* no parity specified, default to 8N1 */
end
if upper(phone.strip.myarg) = 'Y' then do
str on
end /* strip bit 8 on */
else do
str off /* strip bit eight off */
end
do until getpkt(dialport2)= '0000 0000'x end
VLTString = 'schedule (cancel autodialer; autodialer: trap add {CONNECT} [rx (address DIALPORT2 CONN)]; '
VLTString = VLTString || 'trap add {BUSY} [rx (Address DIALPORT2 RD)]; '
VLTString = VLTString || 'trap add {NO DIALTONE} [rx (address DIALPORT2 ND)]; '
VLTString = VLTString || 'trap add {NO CARRIER} [rx (address DIALPORT2 NC)]; '
VLTString = VLTString || 'trap add {OK} [rx (address DIALPORT2 CLOSEWINDOW)]; '
VLTString = VLTString || 'trap add {ERROR} [rx (address DIALPORT2 RD)];'
VLTString = VLTString || ' pause)'
Delayer = 'schedule (cancel delayer; delayer: wait 1:00; rx (address DIALPORT2 TO))'
call openwindow(DIALPORT, 220, 75, 200, 40, "CLOSEWINDOW", "WINDOWCLOSE+WINDOWDRAG", "Close to Cancel")
call move(DIALPORT, 4, 30)
call setApen(dialport, 1)
call Text(DIALPORT, "Click on Close to cancel")
call move(DIALPORT, 4, 20)
call Text(DIALPORT, "Dialing "||strip(phone.name.myarg))
VLTString
Delayer
send '{atdt' strip(phone.number.myarg) '}'
do dummy1 = 1
do dummy2 = 1
token = getpkt(dialport2)
if token = '0000 0000'x then leave dummy2
myarg2 = getarg(token)
call reply(token)
select
when myarg2 = 'CONN' then do
'beep'
if phone.macro.myarg ~= ''
then do
sendstring = "address rexx; call " strip(phone.macro.myarg)||"()"
address vlt
rx "'"sendstring"'"
end
'cancel autodialer'
'cancel delayer'
leave dummy1
end
when myarg2 = 'RD' then do
call delay(100)
send '{atdt' strip(phone.number.myarg) '}'
'cancel delayer'
leave dummy2
end
when myarg2 = 'ND' then do
message '{No dialtone!}'
'cancel autodialer'
'cancel delayer'
leave dummy1
end
when myarg2 = 'NC' then do
message '{No carrier from host!}'
'cancel autodialer'
'cancel delayer'
leave dummy1
end
when myarg2 = 'CLOSEWINDOW' then do
message '{User abort requested}'
'cancel autodialer'
'cancel delayer'
'hangup'
leave dummy1
end
when myarg2 = 'TO' then do
message '{timeout. Aborting dial attempt.}'
'cancel autodialer'
leave dummy1
end
otherwise nop
end
end
call waitpkt(dialport2)
end
call exit(dialport)
exit 0
/* given the starting and ending phone entry numbers, this function
puts up gadgets for them, as well as up and/or down gadgets,
if necceesary. */
dogadgets:
arg start, end, realmax
if start > 1 then call addgadget(dialport, 200, 40, up, "PgUp", up)
if end < realmax then call addgadget(dialport,200, 120, down, "PgDn", down)
do dotemp = start to end
call addgadget(dialport, 12, 11+(15*(dotemp-start)), dotemp, phone.name.dotemp, dotemp)
end
return 1
/* this function takes the starting and ending phone entries
and clears out the gadgets for them, as well as removing
the up and down gadgets, if they appear. */
cleargadgets:
arg start, end
call setAPen(dialport, 0)
if start > 1 then do
call removegadget(dialport, up)
call rectfill(dialport, 198, 39, 250, 56)
end
if end < i then do
call removegadget(dialport, down)
call rectfill(dialport, 198, 119, 250, 136)
end
do dotemp = start to end
call removegadget(dialport, dotemp)
call rectfill(dialport, 10, 10+(15*(dotemp-start)), 145, 11+11+(15*(dotemp-start)))
end
call setapen(dialport, 1)
return 1