home *** CD-ROM | disk | FTP | other *** search
- /* select.vlt--by Warren Block. A dialing macro for VLT, based on: */
-
- /* Dial_Select.vlt - display a list of numbers to dial for mouse selection */
- /* - written by Glenn M. Lewis - Caltech - 12/12/89 */
- /* - based upon an ARexx script in Amazing Computing V4.12 */
- /* */
- /* Do what you want with this code. */
- /* I shall not be held responsible for any use or misuse of this code. */
- /* Since parts of this code were derived from the Amazing Computing article, */
- /* here is the gratuitous notice: */
- /* */
- /* copyright 1989 Richard Lee Stockton and Gramma Software. */
- /* This code is freely distributable as long as this copyright */
- /* notice remains, unchanged, at the start of the code. Thank you. */
- /* */
- /* You are welcome. */
- /* -- Glenn */
-
- title='Select V2.3'
-
- if ~show('L','rexxarplib.library') then do
- call addlib('rexxsupport.library',0,-30,0)
- call addlib('rexxarplib.library',0,-30,0)
- end
-
- if show('Ports','SELECTHOST') then exit
-
- address VLT
-
- predial=0
- numfile='S:VLT.Phone'
- dialfile='t:undialed'
- dialstr='<<< Dial >>>'
- password='AMIGA'
- gadht=14
- maxdialcnt=8
- pausetime=2
- quitfont ='Topaz'
- call setenv(systempassword,password)
- cmdstart ='1b'x||"[?91h"||password||"~@"
- cmdend ='1b'x||"[?91l"
- shellname='NewCLI'
- dialcount=0
- dialstr. =''
-
- if ~exists('C:FastFonts') then
- fontprog='FF'
- else
- fontprog='FastFonts'
- fontprog=fontprog '> NIL:'
-
- 'extract "FUNCTIONKEY"'
- oldF1=VLT.FUNCTIONKEY.1
- "function 1 [~rx 'address SELECTPORT CANCEL']"
-
- vltwidth=screencols('VLT')
- if vltwidth == -1 then do
- screenname=''
- vltwidth=screencols()
- vltheight=screenrows()
- end
- else do
- vltheight=screenrows('VLT')
- screenname='VLT'
- end
- dialx=vltwidth*.06
- dialy=vltheight*.25
- call LoadNumbers(numfile)
-
- rx '{call createhost(SELECTHOST,SELECTPORT'||','||screenname||')}'
- do 500 while ~show('Ports','SELECTHOST')
- call delay(5)
- end
- if ~show('Ports','SELECTHOST') then do
- 'message "Couldn''t open SELECTHOST port."'
- signal CleanExit
- end
-
- maxpercolumn=(vltheight%gadht)-1
- columns=max((gadht*(files.count+2))%vltheight,1)
- if gadht*(files.count+2) > vltheight then
- if gadht*(files.count+1)//vltheight ~= 0 then columns=columns+1
- gadspercolumn=(files.count+1)%columns
- if (files.count+1)//columns ~= 0 then gadspercolumn=gadspercolumn+1
- gadspercolumn=min((vltheight-gadht)%gadht,gadspercolumn)
- w.wid =min(15*(columns+1)+(namelen+1)*8*columns,vltwidth)
- w.hght=min(16+14*gadspercolumn,vltheight)
- w.top =(vltheight-w.hght)/2
- w.left=(vltwidth-w.wid)*.94
- call openwindow(SELECTHOST,w.left,w.top,w.wid,w.hght,,
- 'CLOSEWINDOW+GADGETUP','WINDOWCLOSE+WINDOWDRAG+BACKFILL+ACTIVATE',title)
- do i=0 to files.count
- call addgadget(SELECTHOST,12+(168*(i%gadspercolumn)),,
- 14+14*(i//gadspercolumn),i,gadget.i,gadget.i)
- end
- call openport(SELECTPORT)
-
- if exists(dialfile) then call ReadUndialed
-
- do forever
- call waitpkt(SELECTPORT)
- p=getpkt(SELECTPORT)
- if p ~== NULL() then do
- name=strip(getarg(p))
- call reply(p,0)
- select
- when name == 'CLOSEWINDOW' | name == 'CANCEL' then do
- call postmsg()
- call closewindow(SELECTHOST)
- if exists(dialfile) then
- call DeleteDial
- call SetFont(quitfont)
- signal CleanExit
- end
- when name == dialstr then do
- if dialcount>0 then
- signal StartDialing
- else do
- call closewindow(SELECTHOST)
- signal CleanExit
- end
- end
- otherwise do
- if exists(dialfile) then do
- call DeleteDial
- call postmsg(dialx,dialy,copies('\ ',maxdialcnt),screenname)
- dialcount=0
- dialstr. =''
- end
- call AddName
- end
- end
- end
- end
- exit
-
- DeleteDial:
- address command 'delete' dialfile
- return
-
- SetFont:
- parse arg newfont
- address command fontprog newfont||'.font'
- return
-
- ReadUndialed:
- call open('input',dialfile,'Read')
- dialcount=0
- do until eof('input')
- in=readln('input')
- if length(in)>0 then do
- dialstr.dialcount=in
- dialcount=dialcount+1
- end
- end
- tempstr=''
- do i=0 to maxdialcnt-1
- if dialstr.i ~= '' then tempstr=tempstr||i+1||': '
- tempstr=tempstr||dialstr.i
- if i<maxdialcnt-1 then tempstr=tempstr||'\'
- end
- if dialcount>0 then
- call postmsg(dialx,dialy,tempstr,screenname)
- call close('input')
- return
-
- AddName:
- if dialcount<maxdialcnt then do
- dialstr.dialcount=name
- tempstr=''
- do i=0 to maxdialcnt-1
- if dialstr.i ~= '' then tempstr=tempstr||i+1||': '
- tempstr=tempstr||dialstr.i
- if i<maxdialcnt-1 then tempstr=tempstr||'\'
- end
- call postmsg(dialx,dialy,tempstr,screenname)
- dialcount=dialcount+1
- end
- return
-
- StartDialing:
- dialnum=0
- call closewindow(SELECTHOST,'CONTINUE')
- call postmsg()
- call postmsg(dialx,dialy,copies(' ',namelen+19),
- ||'\'||center('Press F1 To Cancel',namelen+18),screenname)
- do forever
- 'trap add install "CONNECT" (rx [address SELECTPORT CONNECT])'
- 'trap add install "BUSY" (rx [address SELECTPORT BUSY])'
- 'trap add install "NO" (rx [address SELECTPORT NO])'
- 'schedule (Timer: delay 35; rx [address SELECTPORT TIMEOUT])'
- name=dialstr.dialnum
- 'clear'
- 'baud' files.name.pbaud
- call postmsg(dialx,dialy,center('Dialing' files.name.name ,
- '('||files.name.pbaud 'baud)',namelen+18),screenname)
- 'send "*R"'
- if predial ~= 0 then call delay(predial)
- 'send raw "'||'ATDT' files.name.phone||'"'
- 'send "*R"'
- call waitpkt(SELECTPORT)
- 'cancel "Timer"'
- 'trap remove all'
- p=getpkt(SELECTPORT)
- answer=strip(getarg(p))
- call reply(p,0)
- select
- when answer == 'CONNECT' then do
- call postmsg()
- 'clear'
- if files.name.pfont ~= '' then
- call SetFont(files.name.pfont)
- if length(files.name.scp)>0 & exists(files.name.scp) then do
- str=cmdstart||files.name.scp||cmdend
- 'emit raw "'||str||'"'
- end
- do i=dialnum to dialcount-1
- q=i+1
- dialstr.i=dialstr.q
- end
- dialcount=dialcount-1
- call DeleteDial
- if dialcount>0 then do
- call open('output',dialfile,'Write')
- do i=0 to dialcount-1
- call writeln('output',dialstr.i)
- end
- call close('output')
- end
- call closewindow(SELECTHOST)
- signal CleanExit
- end
- when answer == 'CANCEL' then do
- signal StopIt
- end
- otherwise do
- 'send "*R"'
- call postmsg(dialx,dialy,center('Pausing...',namelen+18),screenname)
- 'schedule (Timer: delay ' pausetime '; rx [address SELECTPORT TIMEOUT])'
- call waitpkt(SELECTPORT)
- p=getpkt(SELECTPORT)
- answer=strip(getarg(p))
- call reply(p,0)
- if answer == 'CANCEL' then signal StopIt
- dialnum=dialnum+1
- if dialnum>(dialcount-1) then dialnum=0
- end
- end
- end
- exit
-
- StopIt:
- 'send "*R"'
- call postmsg()
- 'message "'||center('--- Dialer Stopped ---',namelen+18)||'"'
- 'clear'
- call open('output',dialfile,'Write')
- do i=0 to dialcount-1
- call writeln('output',dialstr.i)
- end
- call close('output')
- call closewindow(SELECTHOST)
- call SetFont(quitfont)
-
- CleanExit:
- "function 1 ["||oldF1||"]"
- exit 0
-
- LoadNumbers:
- parse arg filename
- if ~open('input', filename, 'Read') then do
- 'message "Error opening' filename 'for input."'
- signal CleanExit
- end
- template=Readln('input')
- parse var template '|' namelen '|' numblen '|' baudlen '|' fontlen '|'
- namelen=length(namelen)+1
- numblen=length(numblen)+1
- baudlen=length(baudlen)+1
- fontlen=length(fontlen)+1
- i=0
- gadget. =''
- do while ~eof('input')
- line=Readln('input')
- if length(compress(line))<2 | substr(line,1,1) == '|' then iterate
- parse var line 1 bbsname +namelen number +numblen baud +baudlen font +fontlen script .
- name=strip(bbsname)
- files.name.name =name
- files.name.phone=strip(number)
- files.name.pbaud=strip(baud)
- files.name.pfont=strip(font)
- files.name.scp =strip(script)
- gadget.i=center(name,namelen+1,' ')
- i=i+1
- end
- call close('input')
- files.dialstr.name=center(dialstr,namelen+1,' ')
- gadget.i=files.dialstr.name
- files.count=i
- return
-