home *** CD-ROM | disk | FTP | other *** search
- /* select.vlt - Warren Block 05-Jan-90. 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 */
- /* */
- /* Completely reworked by Warren Block, Dec 1989 and Jan 1990: */
- /* * Multiple columns! And the code is bright enough to figure this out */
- /* automatically! It's nifty! It's magic! It's...well, it's free. */
- /* * Automatically adjusts to size of VLT window--no hard-coded sizes */
- /* * Accepts BBS names, numbers, baud rates, and scripts in TFL-like format */
- /* * Improved phone file parsing */
- /* * Lots of drastically changed code (for the better, hopefully) */
- /* * Added "Redial Last" as the last gadget */
- /* * Changed hard-coded values to easily-changed configuration constants */
- /* * Added support for opening the window on a custom screen or Workbench */
-
- /* Make sure necessary ARP library is loaded */
- if ~show('l', "rexxarplib.library") THEN
- call addlib("rexxarplib.library", 0, -30, 0)
-
- address VLT
-
- dialcmd = 'ATDT' /* Standard Hayes-type tone dial command. */
- redialcmd = 'AT*RD9' /* Redial command for my Codex 2233 modem. */
- shellname = 'NewCLI' /* This could be NewShell or whatever. */
- numfile = 'S:VLT.Phone' /* Phone numbers file. */
- csi = '1B'x || '['
-
- vltwidth = ScreenCols("VLT") /* Find size of VLT screen. */
- vltheight = ScreenRows("VLT")
- screenname = "VLT"
- if vltwidth == -1 then do /* If width was -1, it was */
- vltwidth = ScreenCols() /* a Workbench window. */
- vltheight = ScreenRows()
- screenname = ""
- end
-
- /*
- q = Setenv(SystemPassWord,"AMIGA") /* Need for async script startup */
- */
-
- call loadnumbers(numfile)
-
- longest = 19 /* TFL format--19 chars for name */
-
- /* Decide on number of columns for window. Try adding more entries to */
- /* to numfile to see this stuff at work. It auto-sizes the window to */
- /* fit as well as possible into the right side of the current VLT window. */
- columns = vltheight % (14*(files.0+1))
- if 14*(files.0+2) > vltheight then
- if 14*(files.0+1) // vltheight ~= 0 then columns = columns + 1
- gadspercolumn = (files.0+1) % columns
- if (files.0+1)//columns ~= 0 then gadspercolumn = gadspercolumn + 1
- gadspercolumn = min((vltheight - 14) % 14, gadspercolumn)
-
- w.title = "Phone Numbers"
- w.width = min(15*(columns+1)+longest*8*columns, vltwidth)
- w.height = min(16+14*gadspercolumn, vltheight)
- w.topedge = (vltheight-w.height)/2
- w.leftedge = (640-w.width)*.9
- w.idcmp = 'CLOSEWINDOW+GADGETUP'
- w.flags = 'WINDOWCLOSE+WINDOWDRAG+BACKFILL+ACTIVATE'
-
- /* Setup FAVorites Host */
- /* First, write a 2-line temporary file to t: which the 'newcli' */
- /* or 'newshell' commands can use as a startup script. */
-
- call open(f,"t:host.scp","W")
- if screenname == "VLT" then
- call writeln(f, "rx 'Call CreateHost(FAVHOST,FAVPORT,VLT)'")
- else
- call writeln(f, "rx 'Call CreateHost(FAVHOST,FAVPORT,)'")
- call writeln(f, "EndCLI")
- call close(f)
- if screenname == "VLT" then
- address command shellname '"CON:555/175/85/20//" FROM "t:host.scp"'
- else
- address command shellname '"CON:500/175/85/20//" FROM "t:host.scp"'
-
- /* Delay until the HOST had opened its port. */
-
- do 500 while ~SHOW('Ports','FAVHOST') /* Wait up to 10 seconds for port */
- call delay(5) /* Wait 1/10 of a second */
- end
-
- if ~show('Ports', 'FAVHOST') THEN DO /* Host failed to open, quit. */
- say "Couldn't open port FAVHOST."
- exit 10
- end
-
- /* Open the HOST window */
- call OpenWindow(FAVHOST, w.leftedge, w.topedge, w.width, w.height, w.idcmp, w.flags, w.title)
-
- /* Add the gadgets to the HOST window. One gadget per filename. */
- /* WB: added multiple columns. This is uuugglly, but works pretty well. */
- do i=0 to files.0
- call AddGadget(FAVHOST, 12+(168 * (i % gadspercolumn)),14+14*(i//gadspercolumn), i, files.i.name, files.i.name)
- end
-
- /* Open our port. This is where we RECEIVE the signals from the host port */
- /* In this application, FAVHOST sends messages, FAVPORT receives them. */
-
- call OpenPort(FAVPORT)
-
- /* MAIN LOOP */
-
- do forever
- call WaitPkt(FAVPORT) /* Wait for messages at FAVPORT */
- p = GetPkt(FAVPORT)
- IF p ~== NULL() THEN /* Don't process an empty packet */
- do
- thisarg = strip(GetArg(p)) /* Get the argument info from the packet */
- call reply(p,0) /* Always reply() as soon as possible */
-
- if thisarg == 'CLOSEWINDOW' then
- do
- call closewindow(FAVHOST)
- address command 'delete t:host.scp'
- exit 0
- end
-
- do i=0 to files.0
- if thisarg == strip(files.i.name) then break
- end
- if i<files.0+1 then
- do
- call closewindow(FAVHOST)
- address command 'delete t:host.scp'
-
- /* Clear the screen */
- 'emit "' || csi || 'H' || csi || 'J'
-
- /* I don't even want to know why I have to do this... */
- if files.i.baud < 2400 then
- 'bau ' || files.i.baud
- else
- 'baud ' || files.i.baud
-
- call delay(20)
-
- if thisarg == "Redial Last" then
- do
- 'emit "Redialing Last Number *X0D*N"'
- "rawsend " redialcmd
- "send ''*X0D"
- end
- else
- do
- 'send "Dialing:' thisarg '(' || files.i.baud 'baud) *X0D*N"'
- call delay(50)
- 'send "' || dialcmd files.i.number '*X0D"'
- /* code to execute scripts: currently doesn't work */
- /* due to problems with VLT's scripting commands. */
- /*
- if length(files.i.script)>0 & exists(files.i.script) then
- do
- 'emit "*R*NStarting script..."'
- call delay(20)
- outstr = '"' || csi || '?91hAMIGA~@' || files.i.script || csi || '?91l' || '"'
- "emit" outstr
- 'emit "*R*N"'
- end
- */
- end
- exit 0
- end
- end
- end
-
- /* WB: The file format used is the same as that used by The Final */
- /* List. I think so, anyway, since I used to use GT.Term a lot and */
- /* this format is the same. Lines beginning with a vertical bar are */
- /* ignored, so you can add comments. Here is a sample record: */
- /* */
- /* | BBS Name | Phone Number |Baud| Script */
- /* Wonkity World 1 (605) 342-1632 2400 REXX:DialWonkity.scp */
- /* */
- /* Don't use tabs. */
- /* This file should be saved as "VLT.Phone" in the S: directory. */
- /* If you already have a "GT.Phone" file (or something in the same */
- /* format), you should be able to just rename it. Entries following */
- /* the baud rate on the same line are ignored, but may be used later */
- /* for scripts and such. */
-
- loadnumbers:
- parse arg filename
-
- if ~Open('input', filename, 'Read') then do
- "message ''Can not open file:" filename "for input."
- exit 0
- end
- i = 0
- do while ~eof('input')
- line = Readln('input')
- if length(compress(line))<2 | substr(line,1,1) == '|' then iterate
- parse var line 1 files.i.name +18 files.i.number +18 files.i.baud +5 files.i.script .
- files.i.name = center(strip(files.i.name),19,' ')
- files.i.number = strip(files.i.number)
- files.i.baud = strip(files.i.baud)
- files.i.script = compress(files.i.script, ' ' || '0A'x)
- i = i + 1
- end
- call Close('input')
- files.i.name = center('Redial Last',19,' ')
- files.i.number = ''
- files.i.baud = '2400'
- files.0 = i
- return
-