[comp.sys.apple] TIC script correction

delton@pro-carolina.cts.com (Don Elton) (12/28/89)

There were a few bugs in the Dialing directory script I posted several weeks
ago and actually shipped with a few hundred TIC orders.  Here's the new,
improved, (i.e. fixed) version.

------------------------ cut here -----------------------------
# Example Dialing script to let you set up a dialing menu of 9 items for
# Talk is Cheap
#
# Copyright 1989
# By Don Elton
# Carolina System Software
# 3207 Berkeley Forest Drive
# Columbia, SC  29209-4111
#
# pro-carolina = 803-776-3936
 
set statline off
set timer 30
set duplex full
set screen off
display ^L;# clear screen
goto main
 
# Number.Key
Assign "0" 6
if keyboard ^[ goto exit
if keyboard 1 assign "1" 6
if keyboard 2 assign "2" 6
if keyboard 3 assign "3" 6
if keyboard 4 assign "4" 6
if keyboard 5 assign "5" 6
if keyboard 6 assign "6" 6
if keyboard 7 assign "7" 6
if keyboard 8 assign "8" 6
if keyboard 9 assign "9" 6
return        
 
# Valid.Baud
if null 3 goto nobaud
if equal "$3" "300" goto okb   
if equal "$3" "1200" goto okb   
if equal "$3" "2400" goto okb   
if equal "$3" "4800" goto okb   
if equal "$3" "9600" goto okb   
if equal "$3" "19200" goto okb   
# nobaud
assign ".NoBaud." 3                
# okb  
return           
 
# waitany
waitfor keyboard
if keyboard ^[ goto exit
return
 
# exit
display ^L
set statline on
set screen on
display " ^H"
stop
 
# main
window 10,70,4,20
gotoxy 25,6
display "Master Dialing Script"
gotoxy 15,8
display "1    Dial a service"
gotoxy 15,9
display "2    List services"
gotoxy 15,10
display "3    Add a service"
gotoxy 15,11
display "4    Delete a service"
gotoxy 15,18
display "Press the key of your choice: "
 
# waitkey
waitfor keyboard
if keyboard ^[ goto exit
if keyboard 1 goto dial.svc
if keyboard 2 goto list.svc
if keyboard 3 goto add.svc
if keyboard 4 goto del.svc
display ^G
goto main
 
# dial.svc
window 10,70,4,20
gotoxy 25,6
display "Dial a Service:"
do do.list
gotoxy 15,18
display "Press key of choice or M for manual: "
# wait.dial
waitfor keyboard
do Number.Key
if Keyboard "M" Goto skipload
Display "$6"
 
assign "1" 5
if exists "$RootDial.Dta" goto okfile
goto main;# no file found
 
# okfile
open 0 "$RootDial.Data"
# readloop.1
readfile 0 1;readfile 0 2;readfile 0 3;readfile 0 4
if equal "$5" "$6" goto skipload2
if null 1 close 0;goto main
inc 5
goto readloop.1
 
# skipload
assign ".Null." 1
assign ".Null." 2
assign ".NoBaud." 3
assign ".NoChain." 4
 
# skipload2
window 10,70,4,20
gotoxy 25,6
display "Dial: "
if equal "$1" ".Null." display "Manual Entry";goto donum
display $1
 
# donum
gotoxy 0,8
display " "
gotoxy 15,8
display "Number: "
if equal "$2" ".Null." getline 2;goto donum
display "$2"
 
# dobaud
gotoxy 0,9
display " "
gotoxy 15,9
display "  Baud: "
do Valid.Baud
if equal "$3" ".NoBaud." getline 3;goto dobaud
display "$3"
 
# HowMany?
gotoxy 15,11
display "Dial how many times (1-9): ^O ^N^H"
waitfor keyboard
assign "0" 7
do Number.Key
if equal "$6" "0" goto HowMany?
display "$6"
# DisplayCount
gotoxy 15,13
inc 7
display "Dialing attempt #$7 in progress."
gotoxy 15,15
dec 6
display "$6 attempts remain."
 
set timer 20
set baud $3
# dialit
xmit "ATDT$2^M"
waitfor string "CONNECT"
if failed goto abort.dial
 
if equal "$4" ".NoChain." display "^G^GConnected...";pause 1;goto exit
set statline on
display ^L
set screen on
if exists "$4" chain "$4"
if exists "$root$4" chain "$root$4"
stop
 
# abort.dial
if equal "$6" "0" goto main
goto DisplayCount
# list.svc
window 10,70,4,20
gotoxy 28,6
display "Service Listing:"
do do.list
gotoxy 15,18
display "Press any key..."
waitfor keyboard
if keyboard ^[ goto exit
goto main
 
# do.list
if exists "$RootDial.Data" goto gotfile
goto list.done
 
# gotfile
assign "1" 6;# number.for.svc
assign "8" 5;# for.line.number
open 0 "$RootDial.Data"
# read.list
readfile 0 1;readfile 0 2;readfile 0 3;readfile 0 4
if null 1 goto end.list
gotoxy 12,$5
display "$6:"
gotoxy 15,$5
display "$1"
gotoxy 38,$5
display "$2"
gotoxy 48,$5
display "$3"
gotoxy 55,$5
display "$4"
inc 5
inc 6
if equal "$6" "10" goto end.list
goto read.list
 
# end.list
close 0
 
# list.done
return
 
# add.svc
window 10,70,4,20
gotoxy 25,6
display "Add a service:"
# tryname
gotoxy 15,8
display "Enter service name: "
getline 1;display " "
if null 1 goto main
gotoxy 15,9
display "Enter phone number: "
getline 2;display " "
if null 2 goto main
 
# getbaud
gotoxy 15,10
display "   Enter baud rate: "
getline 3;display " "
do Valid.Baud       
if equal "$3" ".NoBaud.";display ^G;goto getbaud
 
gotoxy 15,11
display "Enter Logon Script name: "
getline 4;display " "
if null 4 assign ".NOCHAIN." 4
 
opena 0 "$RootDial.Data"
writefile 0 "$1^M$2^M$3^M$4^M"
close 0
goto main
 
# del.svc
window 10,70,4,20
gotoxy 25,6
display "Delete a service:"
do do.list
gotoxy 15,18
display "Delete which service? "
 
# test.del.num
waitfor keyboard
if keyboard ^M goto main
if keyboard ^[ goto exit
do Number.Key
if equal "0" 6 display ^G;goto test.del.num
display $6
 
if exists "$WorkDial.Temp" delete "$WorkDial.Temp"
assign "1" 5;# starting record number
 
open 0 "$RootDial.Data"
open 1 "$WorkDial.Temp"
# read.del
readfile 0 1;readfile 0 2;readfile 0 3;readfile 0 4
if null 1 goto done.copy
if equal "$6" "$5" goto skip.write
writefile 1 "$1^M$2^M$3^M$4^M"  
 
# Skip.Write
inc 5
goto read.del
 
# Done.Copy
close 0
close 1
delete "$RootDial.Data"
buffer load "$WorkDial.Temp"
buffer write "$RootDial.Data"
delete "$WorkDial.Temp"
goto main
 

UUCP: [ sdcsvax nosc ] !crash!pro-carolina!delton
ARPA: crash!pro-carolina!delton@nosc.mil
INET: delton@pro-carolina.cts.com

Pro-Carolina: 803-776-3936 (300-2400 baud, login as 'register')
     US Mail: 3207 Berkeley Forest Drive, Columbia, SC  29209-4111
         CIS: 72010,37   MCI: 351-9930   GEnie: delton