home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
x
/
xtalk1.zip
/
ANSWER.ZIP
/
ANSWER.XWS
< prev
Wrap
Text File
|
1993-03-05
|
30KB
|
1,361 lines
/*
Crosstalk for Windows Answer Mode Script
This script provides an unattended 'answer mode' to answer outside calls.
The NetID is used by this script to limit callers to a specific directory.
Copyright (C) 1989, 1993 Digital Communications Associates, Inc.
All Rights Reserved.
For Version 2.0 06-08-92 KMP
Version 00 01-19-93 PJL - General fixes
Version 01 02-03-93 PJL - More fixes
Version 02 03-05-93 PJL - Script Cancel, Error on Go fixes
*/
ScriptDesc "Answer calls"
include "SERVFUNC.XWS"
assume device "DCAMODEM.PRE"
assume protocol "DCAXYMDM.PRE"
assume terminal "DCATTY.PRE"
/***************************************************************************
This script accomplishes two things:
1) Setup a phone book entry (ANSWER.XWP) for answer mode. When run
offline against a phone book entry with Patience set to 10, this
script assumes that this phone book has not been configured and
will ask the user several questions including login passwords,
directory access restrictions and caller activity restrictions.
*** NOTE: To reconfigure ANSWER.XWP, set "Seconds to allow host
to answer" value, in Settings.Connection dialog, to 10.
2) After a connection has been established the users (both remote
and local) get a menu (a la Crosstalk Mk.4/Communicator 2.1) of
things to do. The current directory is automatically set to either
the DownloadDir (session setting) or DirFil (workstation setting).
****************************************************************************
USER DEFINABLE VARIABLES:
-------------------------
Change the following variables for your requirements:
1) string "Accept"
The file access level for the caller, works like Crosstalk Mk.4's
Accept variable.
Valid values for this string are:
"All" - Allow all accesses. Read, Write, Create, etc.
"Append" - Allows only appending to existing files. Cannot
create new files.
"Create" - Allows only creation of new files. Cannot overwrite
or erase old files.
"None" - Allows no uploading, only downloading.
2) Settings.Session "NetID" variable:
If this value contains the string "DirRestrict", then callers are
restricted to the current download directory. The Settings.Session
"DownloadDir" directory is used; if this variable is empty, then the
Settings.Workstation "DirFil" directory is used.
***************************************************************************/
/*
USER DEFINABLE VARIABLE DECLARATIONS & INITIALIZATIONS
*/
string Accept
Accept = "All" -- default
/*
INTERNAL VARIABLE DECLARATIONS/INITIALIZATIONS - DO NOT CHANGE
*/
boolean expert, driveLock, msgFileOpen, callerBye
string S_Q_C, NEW_STR, USER_NAME, MESSAGE_FILE
string savDrive, savDir
driveLock = FALSE : msgFileOpen = FALSE
MESSAGE_FILE = HomeDir + "\ANSWER.MSG"
S_Q_C = "Press Ctrl-S to pause, Ctrl-Q to resume, Ctrl-C to terminate."
/*
PROCEDURE AND FUNCTION DECLARATIONS
*/
proc SET_DRIVE takes string cDrive
if upcase(cDrive) <> upcase(left(curDrive, 1)) then
{
drive cDrive
}
endproc
proc SET_DIRFIL takes boolean fReset
if fReset then
{
if not null(savDrive) then SET_DRIVE savDrive
if not null(savDir) then cd savDir
}
else
{
savDrive = "" : savDir = ""
if not null(DownloadDir) then
{
-- Switch to session download directory, if there is one.
savDir = curDir
SET_DRIVE left(DownloadDir, 1)
cd DownloadDir
}
else if not null(DirFil) then
{
-- Switch to Workstation DirFil directory, if there is one.
savDir = curDir
SET_DRIVE left(DirFil, 1)
cd DirFil
}
}
endproc
/*
CHECK
Check for errors and lost connection. End the script if we get either
of these recycling to answer more calls.
*/
proc CHECK
if callerBye then exit
if not Online then {
wait 5 ticks
e = error
bye
wait 5 ticks
e = error
errmsg = 'Lost Connection'
print
print errmsg
print
capture off
SET_DIRFIL TRUE -- Reset original directory.
chain HomeDir + "\XWP20\ANSWER.XWS"
}
if error then {
errmsg = str(errclass) + ' - ' + str(errno)
if errclass = 13 and errno = 12 then errmsg = 'File(s) not found'
else if errclass = 20 then errmsg = 'Lost Connection'
else if errclass = 45 then {
case errno of
1: errmsg = "General timeout"
2: errmsg = "Host not responding"
3: errmsg = "Bad response from host"
4: errmsg = "Maximum errors exceeded"
5: errmsg = "Transfer cancelled"
7: errmsg = "Transfer cancelled"
8: errmsg = "Transfer cancelled"
10: errmsg = "File(s) not found"
11: errmsg = "Local disk full"
12: errmsg = "Host disk full"
15: errmsg = "Local system busy"
18: errmsg = "Host BlockSize must be 1,2,3 or 4"
endcase
}
errmsg = "Error: " + errmsg
print
reply
print errmsg
reply errmsg
print
reply
}
endproc
/*
PRINT_SEND
Print the string on the screen and send it the host. Watch for lost
connection at the same time. Note that if no SendString is passed in,
a return is displayed. Also, a line feed is added to data sent to the
caller.
*/
proc PRINT_SEND takes optional string SendString
print SendString
CHECK
reply SendString
reply chr(10);
CHECK
endproc
/*
GET_COMMAND
Send the menu prompt and get the answer from the user.
*/
function GET_COMMAND (string P) returns string
string NEW_STR
PRINT_SEND
CHECK
PRINT_SEND
P = P + chr(32)
print P;
reply P;
CHECK
ExitNow = FALSE
while not ExitNow
CHECK
inChar = nextchar
if not null(inChar) then {
if inChar = chr(13) then {
ExitNow = TRUE
}
else if inChar = chr(8) then {
if not null(NEW_STR) then {
if length(NEW_STR) = 1 then {
NEW_STR = ""
}
else
{
NEW_STR = left(NEW_STR, length(NEW_STR) - 1)
}
}
}
else {
NEW_STR = NEW_STR + inChar
}
print inChar;
reply inChar;
}
else {
UserKey = inkey
if UserKey <> 0 then {
if UserKey = 13 then {
ExitNow = TRUE
}
else if UserKey = 8 then {
if not null(NEW_STR) then {
if length(NEW_STR) = 1 then {
NEW_STR = ""
}
else
{
NEW_STR = left(NEW_STR, length(NEW_STR) - 1)
}
}
}
else {
NEW_STR = NEW_STR + chr(UserKey)
}
print chr(UserKey);
reply chr(UserKey);
}
}
wend
PRINT_SEND
CHECK
return(NEW_STR)
endfunc
/*
PETC
This proc asks the user to 'press enter to continue'.
*/
proc PETC
NEW_STR = GET_COMMAND ("Press Enter to continue.")
endproc
/*
LOCK_NEW_STR
Forces NEW_STR to be in the locked dir if appropriate.
*/
proc LOCK_NEW_STR
if driveLock then NEW_STR = DownloadDir
endProc
proc DRIVE_LOCK_CHECK
if not null(DownloadDir) then
{
if NetID = "DirRestrict" then driveLock = TRUE
else driveLock = FALSE
}
else driveLock = FALSE
endproc
/*
CHECK_DRIVE_ERROR
Check for what drive error and put a message on the screen
Returns a boolean indicating an error occured.
*/
func CHECK_DRIVE_ERROR (string FileSpec) returns boolean
x = error
if not x then return (x)
print "Error: ";
reply "Error: ";
case errclass of
16: {
case errno of
1: PRINT_SEND "Device is write-protected"
3: PRINT_SEND "Drive not ready"
default: PRINT_SEND "Unknown error " + str(errclass) + "-" + str(errno)
endcase
}
19: {
case errno of
2: PRINT_SEND "File not found - " + FileSpec
3: PRINT_SEND "Path not found - " + FileSpec
4: PRINT_SEND "No file handles left"
5: PRINT_SEND "Access denied to " + FileSpec
15: PRINT_SEND "Invalid drive - " + Filespec + ":"
19: PRINT_SEND "Diskette is write-protected"
20: PRINT_SEND "Can't use DOS device as file"
22: PRINT_SEND "Invalid characters in file name"
default: PRINT_SEND "Unknown error " + str(errclass) + "-" + str(errno)
endcase
}
default: PRINT_SEND "Unknown error " + str(errclass) + "-" + str(errno)
endcase
return(x)
endfunc
/*
DO_FILE_LIST
This proc lists the files on the screen 4 across.
*/
proc DO_FILE_LIST takes string FileSpec
integer FileSpacing, SpaceCount, MaxColumn, CurrentColumn, Attributes, nLen
string FileName, DirName, Fspec, sDir
/* Check for root directory */
if right(FileSpec, 1) = "\" then {
FileSpec = FileSpec + "*.*"
}
else if right(FileSpec, 1) = ":" then {
FileSpec = FileSpec + "\*.*"
}
else if right(FileSpec, 3) <> "*.*" then {
if right(FileSpec, 2) <> "*." then {
Attributes = fileattr(FileSpec,10h) & 10h
anError = Error
if Attributes = 10h then {
FileSpec = FileSpec + "\*.*"
}
}
}
-- Parse out the directory name.
DirName = ""
nLen = length(FileSpec) - 1
while nLen > 0
Fspec = mid(FileSpec, nLen, 1)
if Fspec = "\" then {
DirName = left(FileSpec, nLen)
nLen = 0
}
else nLen = nLen - 1
wend
-- If we didn't find one, use the current directory.
if null(DirName) then {
DirName = curDrive + curDir
if right(DirName, 1) <> "\" then {
FileSpec = DirName + "\" + FileSpec
}
else {
FileSpec = DirName + FileSpec
}
}
else if left(DirName, 1) = "\" then {
DirName = curDrive + DirName
}
FileSpacing = 18
InterSpacing = 6
nLen = FileSpacing + InterSpacing
MaxColumn = (80 / nLen) * nLen
CurrentColumn = 1
PRINT_SEND
FileName = filefind(FileSpec,10h)
if null(FileName) then {
PRINT_SEND "No files found for " + upcase(FileSpec)
exit
}
PRINT_SEND
PRINT_SEND S_Q_C
PRINT_SEND
wait 1 second
PRINT_SEND " Directory: " + upcase(FileSpec)
PRINT_SEND
anError = CHECK_DRIVE_ERROR(FileSpec)
if anError then exit
while not null(FileName)
while CurrentColumn < MaxColumn and not null(FileName)
-- Parse out the base file name.
nLen = length(FileName) - 1
while nLen > 0
if mid(FileName, nLen, 1) = "\" then {
FileName = right(FileName, length(FileName)-nLen)
nLen = 0
}
else nLen = nLen - 1
wend
CHECK
print FileName;
reply FileName;
NameLength = length(FileName)
if FileName = "." or FileName = ".." then {
Attributes = 10h
}
else {
Fspec = DirName + FileName
Attributes = fileattr(Fspec,10h) & 10h
}
if Attributes = 10h then {
SpaceCount = 13 - NameLength
sDir = pad("", SpaceCount, " ", 1) + "<DIR>"
print sDir;
reply sDir;
SpaceCount = InterSpacing
}
else {
SpaceCount = (FileSpacing - NameLength) + InterSpacing
}
print pad("", SpaceCount, " ", 1);
reply pad("", SpaceCount, " ", 1);
CurrentColumn = CurrentColumn + FileSpacing + InterSpacing
FileName = filefind
anError = CHECK_DRIVE_ERROR(FileName)
if anError then exit
watch 1 tick for
chr(3) : exit
endwatch
wend
PRINT_SEND
CurrentColumn = 1
wend
endproc
/*
UPLOAD_FILE
Takes a file name as a parameter. If not there it asks the user to
enter one. It then issues the appropriate user instructions for
the protocol selected and uploads the file.
*/
proc UPLOAD_FILE takes FNAME
case protocol of
"DCAXYMDM" : if upcase(left(ProtoModel,1)) = "X" then flag = 1
else flag = 2
"ZMODEM", ...
"DCAZMDM" : flag = 3
"DART", ...
"DCADART" : flag = 4
"XTALK", ...
"DCAXTALK" : flag = 5
endcase
if not null(FNAME) then NEW_STR = FNAME
else {
if flag = 1 then {
PRINT_SEND
NEW_STR = GET_COMMAND ("Name of file you're uploading to this host?")
CHECK
if null(NEW_STR) then exit
}
}
CHECK
LOCK_NEW_STR
PRINT_SEND
case flag of
1 : PRINT_SEND "Ready for XMODEM upload..."
2 : PRINT_SEND "Ready for YMODEM upload..."
3 : PRINT_SEND "Ready for ZMODEM upload..."
4 : PRINT_SEND "Ready for DART upload..."
5 : PRINT_SEND "Ready for Crosstalk upload..."
endcase
PRINT_SEND "Now give your computer the command to start the transfer."
if flag < 3 then {
PRINT_SEND
wait 6 seconds
if flag = 2 then NEW_STR = ""
receive NEW_STR
}
else {
PRINT_SEND "Press `^Z to return to the answer menu when transfer completes."
PRINT_SEND
done = FALSE
repeat
CHECK
wait 1 tick for "^Z", key 26
if not timeout then done = TRUE
until done = TRUE
}
endproc
/*
DOWNLOAD_FILE
Takes a file name as a parameter. If not there it asks the user to
enter one. It then issues the appropriate user instructions for
the protocol selected and downloads the file.
*/
proc DOWNLOAD_FILE takes FNAME
case protocol of
"DCAXYMDM" : if upcase(left(ProtoModel,1)) = "X" then flag = 1
else flag = 2
"ZMODEM", ...
"DCAZMDM" : flag = 3
"DART", ...
"DCADART" : flag = 4
"XTALK", ...
"DCAXTALK" : flag = 5
endcase
if flag < 4 then {
if null(FNAME) then {
PRINT_SEND
FNAME = GET_COMMAND ("Name of file to download to your computer?")
if null(FNAME) then exit
}
}
CHECK
NEW_STR = ""
LOCK_NEW_STR
if not null (NEW_STR) then {
if instr(FNAME, ':') <> 0 or instr(FNAME, '\') <> 0 then {
PRINT_SEND
PRINT_SEND "Access is restricted to the current download directory."
PRINT_SEND
exit
}
NEW_STR = NEW_STR + "\" + FNAME
}
else {
s = FNAME
if instr(s, ':') = 0 then {
if instr(s, '\') = 0 then {
NEW_STR = curDrive + curDir
if right(NEW_STR, 1) <> '\' then ...
NEW_STR = NEW_STR + '\' + s
else ...
NEW_STR = NEW_STR + s
}
else NEW_STR = curdrive + s
}
else if instr(s, '\') = 0 then {
newDir = upcase(left(s, 1))
savDir = upcase(left(curDir,1))
if newDir <> savDir then {
drive newDir
NEW_STR = curDrive + curDir
drive savDir
s = right(s, length(s)-2)
}
else NEW_STR = curDrive + curDir
if right(NEW_STR, 1) <> '\' then ...
NEW_STR = NEW_STR + '\' + s
else ...
NEW_STR = NEW_STR + s
}
}
if (flag < 4) and (not exists(NEW_STR)) then {
PRINT_SEND
PRINT_SEND "File not found - "+chr(34)+upcase(NEW_STR)+chr(34)
PRINT_SEND
exit
}
PRINT_SEND
case flag of
1 : PRINT_SEND "Ready for XMODEM download..."
2 : PRINT_SEND "Ready for YMODEM download..."
3 : PRINT_SEND "Ready for ZMODEM download..."
4 : PRINT_SEND "Ready for DART download..."
5 : PRINT_SEND "Ready for Crosstalk download..."
endcase
PRINT_SEND "Now give your computer the proper command to effect the transfer."
if flag < 4 then {
PRINT_SEND
wait 2 seconds
send NEW_STR
if flag = 3 then wait 2 seconds for "OO"
}
else
{
savDownloadDir = DownloadDir
DownloadDir = curDrive + curDir
PRINT_SEND "Press `^Z to return to the answer menu when transfer completes."
PRINT_SEND
done = FALSE
repeat
CHECK
wait 1 tick for "^Z", key 26
if not timeout then done = TRUE
until done = TRUE
DownloadDir = savDownloadDir
}
endproc
proc SELECT_PROTOCOL takes PNAME
case upcase(PNAME) of
"XTALK", ...
"DCAXTALK" : NEW_STR = "1"
"XMODEM" : NEW_STR = "2"
"XMODEM/CRC" : NEW_STR = "3"
"XMODEM/1K" : NEW_STR = "4"
"XMODEM/G" : NEW_STR = "5"
"YMODEM", ...
"YMODEM/BATCH" : NEW_STR = "6"
"YMODEM/G" : NEW_STR = "7"
"ZMODEM", ...
"DCAZMDM" : NEW_STR = "8"
"DART", ...
"DCADART" : NEW_STR = "9"
default : goto ASK_PROTO_NAME
endcase
goto SET_PROTO_NAME
label ASK_PROTO_NAME
PRINT_SEND
if Protocol = "DCAXYMDM" then {
PRINT_SEND "Current protocol is " + ProtoModel
}
else if Protocol = "DCAXTALK" then {
PRINT_SEND "Current protocol is XTALK"
}
else {
PRINT_SEND "Current protocol is " + Protocol
}
PRINT_SEND
PRINT_SEND " 1 - Crosstalk"
PRINT_SEND " 2 - Xmodem"
PRINT_SEND " 3 - Xmodem/CRC"
PRINT_SEND " 4 - Xmodem/1K"
PRINT_SEND " 5 - Xmodem/G"
PRINT_SEND " 6 - Ymodem/Batch"
PRINT_SEND " 7 - Ymodem/G"
PRINT_SEND " 8 - Zmodem"
NEW_STR = GET_COMMAND ("Choose a new protocol:")
label SET_PROTO_NAME
case NEW_STR of
"1": protocol = "DCAXTALK"
"2": protocol = "DCAXYMDM" : ProtoModel = "Xmodem"
"3": protocol = "DCAXYMDM" : ProtoModel = "Xmodem/CRC"
"4": protocol = "DCAXYMDM" : ProtoModel = "Xmodem/1K"
"5": protocol = "DCAXYMDM" : ProtoModel = "Xmodem/G"
"6": protocol = "DCAXYMDM" : ProtoModel = "Ymodem/Batch"
"7": protocol = "DCAXYMDM" : ProtoModel = "Ymodem/G"
"8": protocol = "DCAZMDM"
"9": protocol = "DCADART"
"" : exit
default : goto ASK_PROTO_NAME
endcase
endproc
proc DIR_COMMAND takes FNAME
CHECK
if null(FNAME) then {
FNAME = GET_COMMAND ("Enter file specification:")
if null(FNAME) then FNAME = curDrive + curDir
}
else PRINT_SEND
CHECK
-- if we're drive locked, don't allow looking anywhere else.
NEW_STR = ""
LOCK_NEW_STR
if not null(NEW_STR) then {
if instr(FNAME, ":") = 0 and instr(FNAME, "\") = 0 then {
FNAME = NEW_STR + "\" + FNAME
}
}
DO_FILE_LIST FNAME
PETC
endproc
proc DRIVE_COMMAND takes FNAME -- but ignores it
PRINT_SEND
PRINT_SEND "Current drive and directory is " + curDrive + curDir
NEW_STR = GET_COMMAND ("Enter the drive to use:")
if null(NEW_STR) then NEW_STR = curdrive
tmpDrive = left(NEW_STR,1)
drive tmpDrive
anError = CHECK_DRIVE_ERROR(tmpDrive)
if anError then exit
NEW_STR = GET_COMMAND ("Enter new directory:")
if null(NEW_STR) then NEW_STR = curDir
cd NEW_STR
anError = CHECK_DRIVE_ERROR(NEW_STR)
if not anError then PRINT_SEND
endproc
/*
LEAVE_MESSAGE
Leave a message in the message file.
*/
proc LEAVE_MESSAGE
integer chMessage
if null(USER_NAME) then {
NEW_STR = GET_COMMAND("Please enter your name:")
USER_NAME = NEW_STR
}
PRINT_SEND
PRINT_SEND "Please type your message, pressing Enter at the end of each line."
PRINT_SEND "Press Ctrl-Z to end message."
PRINT_SEND
CHECK
chMessage = freefile
open append MESSAGE_FILE as #chMessage
defoutput = chMessage
write line ""
write line "%Message ID: " + str(date)
write line "From: " + USER_NAME
write line "Date: " + date
write line "Time: " + strip(time(-1), chr(0), 0)
write line ""
msgFileOpen = TRUE
CHECK
IN_STR = ""
done = FALSE
while not done
CHECK
inChar = nextchar
while inChar <> ""
print inChar; : reply inChar;
case inChar of
chr(13): PRINT_SEND : write line IN_STR : IN_STR = ""
chr(8), ...
chr(127): if not null(IN_STR) then
{
if length(IN_STR) = 1 then ...
IN_STR = ""
else ...
IN_STR = left(IN_STR, length(IN_STR) - 1)
}
chr(26): done = TRUE
default: IN_STR = IN_STR + inChar
endcase
CHECK
inChar = nextchar
wend
wend
close #chMessage
msgFileOpen = FALSE
endproc
proc READ_MESSAGE
if not exists(MESSAGE_FILE) then {
PRINT_SEND ''
PRINT_SEND 'No messages on file'
PRINT_SEND ''
exit
}
fn = freefile
open input MESSAGE_FILE as #fn
if error then print "Error opening file"
trash = ""
repeat
CHECK
read line #fn, trash
PRINT_SEND trash
-- wait 1 tick for chr(3), key 3, key 27
-- until eof(fn) = TRUE or timeout = FALSE
until eof(fn) = TRUE
close #fn
PETC
endproc
proc PAGE_OPERATOR
alarm 3
PRINT_SEND
PRINT_SEND "Paging operator, please wait ... press Ctrl-Z to abort."
PRINT_SEND
ctr = 0
done = FALSE
repeat
ctr = ctr + 1
if ctr => 5 then done = TRUE
if ctr > 1 then alarm 0
print ".";
reply ".";
watch 5 seconds for
key 0 : done = TRUE
chr(26) : exit
endwatch
CHECK
until done = TRUE
if ctr => 5 then {
PRINT_SEND
PRINT_SEND
PRINT_SEND "Please try again later; the operator is not available."
PRINT_SEND
exit
}
PRINT_SEND
PRINT_SEND "Just type, pressing Enter at the end of each line."
PRINT_SEND "Press Ctrl-Z to end chat session."
PRINT_SEND
IN_STR = ""
OUT_STR = ""
done = FALSE
repeat
CHECK
inChar = nextchar
if inChar <> "" then
{
print inChar;
reply inChar;
case inChar of
chr(13): PRINT_SEND : IN_STR = ""
chr(8), ...
chr(127): if not null(IN_STR) then
{
if length(IN_STR) = 1 then ...
IN_STR = ""
else ...
IN_STR = left(IN_STR, length(IN_STR) - 1)
}
chr(26): done = TRUE
default: if asc(inChar) > 31 then ...
IN_STR = IN_STR + inChar
endcase
}
else {
outKey = inkey
if outKey <> 0 then
{
print chr(outKey);
-- reply chr(outKey);
case outKey of
13: PRINT_SEND : OUT_STR = ""
8,127: if not null(OUT_STR) then
{
if length(OUT_STR) = 1 then ...
OUT_STR = ""
else ...
OUT_STR = left(OUT_STR, length(OUT_STR) - 1)
}
26: done = TRUE
default: if outKey > 31 then ...
OUT_STR = OUT_STR + chr(outKey)
endcase
}
}
until done = TRUE
endproc
/*
ANSWER_MENU
Put up the online menu and wait for a response
*/
proc ANSWER_MENU
string command_line, command_letter, command_arg, pm, ps
PRINT_SEND
PRINT_SEND
PRINT_SEND
PRINT_SEND " Utilities: Options:"
PRINT_SEND " (F)ile directory e(X)pert mode on/off"
if driveLock then {
PRINT_SEND " (P)age the host operator (G)oodbye"
}
else {
PRINT_SEND " (C)hange Host drive/directory (G)oodbye"
TmpCurDir = curDrive + curDir
print " (now ";
reply " (now ";
NumSpaces = 26 - length(TmpCurDir)
if NumSpaces >= 0 then {
print TmpCurDir + ")";
reply TmpCurDir + ")";
TheSpaces = pad("",NumSpaces + 3," ",1)
print TheSpaces;
reply TheSpaces;
}
else {
TmpCurDir = "..." + right(TmpCurDir,26)
print TmpCurDir + ")";
reply TmpCurDir + ")";
}
PRINT_SEND " (P)age the host operator"
}
PRINT_SEND
PRINT_SEND " File Transfers: Message functions:"
PRINT_SEND " (D)ownload to your computer (R)ead messages"
if Accept = "All" or Accept = "Append" or Accept = "Create" then {
PRINT_SEND " (U)pload to Host computer (L)eave a message"
}
if Protocol = "DCAXYMDM" then {
PRINT_SEND " (S)elect protocol (now " + ProtoModel + ")"
}
else if Protocol = "DCAXTALK" then {
PRINT_SEND " (S)elect protocol (now XTALK)"
}
else {
PRINT_SEND " (S)elect protocol (now " + Protocol + ")"
}
PRINT_SEND
endproc
/*
ANSWER_COMMAND
This proc puts up the command line and waits for a response.
It then dispatches the command and returns.
*/
proc ANSWER_COMMAND
if driveLock then ps = "("
else ps = "(C,"
case Accept of
'All', ...
'Append' : ps = ps + "U,D,L"
'Create' : ps = ps + "U,D"
'None' : ps = ps + "D"
endcase
ps = ps + ",R,F,P,X,G,S)?"
command_line = GET_COMMAND ("Command " + ps)
if null(command_line) or ...
(length(command_line) > 2 and mid(command_line,2,1) <> chr(32)) then {
command_letter = ""
}
else {
command_letter = upcase(left(command_line, 1))
command_arg = strip(mid(command_line, instr(command_line + chr(32), chr(32))), 1, 3)
ps = strip(ps, 1, 0)
ps = strip(ps, "(,?)", 0)
ps = upcase(ps) + "H?"
if instr(ps, command_letter) = 0 then {
command_letter = "XYZZY"
}
}
CHECK
case command_letter of
"G" : PRINT_SEND "Goodbye!" : callerBye = TRUE : wait 2 seconds : bye
"X" : expert = not expert
"L" : LEAVE_MESSAGE
"R" : READ_MESSAGE
"U" : UPLOAD_FILE command_arg
"D" : DOWNLOAD_FILE command_arg
"F" : DIR_COMMAND command_arg
"C" : DRIVE_COMMAND command_arg
"S" : SELECT_PROTOCOL command_arg
"P" : PAGE_OPERATOR
"H", "?" : expert = FALSE
"XYZZY" : { PRINT_SEND
PRINT_SEND "That function is not available."
PRINT_SEND
}
endcase
endproc
/*
CHECK_PASSWORD
Ask caller for login password.
*/
function CHECK_PASSWORD returns boolean
integer i
boolean GotPword
if null(Password) then return(TRUE)
i = 1
GotPword = FALSE
while i <= 3 and GotPword = FALSE
PRINT_SEND
reply "Enter password: ";
NEW_STR = nextline(120, Columns)
if upcase(NEW_STR) <> upcase(Password) then i = i + 1
else GotPword = TRUE
wend
return(GotPword)
endfunc
/*
GET_PASSWORD
Ask if they want to password protect the system.
*/
function GET_PASSWORD returns integer
string NewPword
DialogBox 50, 50, 256, 95, 'Answer a call'
LText 14, 11, 179, 8, "In order to restrict access to your PC, you can require"
LText 14, 21, 179, 8, "a password before callers are allowed to connect."
LText 14, 31, 179, 8, "Enter the password required for access below, or"
LText 14, 41, 179, 8, "leave blank for no password protection."
LText 23, 70, 35, 8, "&Password:"
EditText 63, 67, 123, 12, Password, NewPword, TABSTOP
DefPushButton 207, 9, 40, 14, "OK", TABSTOP
PushButton 207, 28, 40, 14, "Cancel", CANCEL TABSTOP
EndDialog
if Choice = 1 then Password = NewPword
return (Choice)
endfunc
/*
GET_DOWNLOADDIR
Ask for the default download directory.
*/
function GET_DOWNLOADDIR returns integer
string NewDownDir
DialogBox 50, 50, 261, 80, 'Answer a call'
LText 14, 11, 186, 8, "The download directory is the directory to store received"
LText 14, 21, 186, 8, "files. Enter the default directory below, or leave blank"
LText 14, 31, 186, 8, "for no default."
LText 20, 58, 75, 8, "&Download Directory:"
EditText 90, 55, 131, 12, DownloadDir, NewDownDir, TABSTOP
DefPushButton 207, 9, 40, 14, "OK", TABSTOP
PushButton 207, 28, 40, 14, "Cancel", CANCEL TABSTOP
EndDialog
/* show lock dir */
if Choice = 1 then DownloadDir = NewDownDir
return (Choice)
endfunc
/*
GET_LOCK_DIR
Ask to lock the directory for transfers to the download dir.
*/
function GET_LOCK_DIR returns integer
DialogBox 50, 50, 256, 59, 'Answer a call'
LText 14, 11, 179, 8, "You can restrict callers to the default download"
LText 14, 21, 179, 8, "directory, or allow them unrestricted directory access."
LText 14, 31, 179, 8, "Do you wish to restrict callers to the default download"
LText 14, 41, 179, 8, "directory?"
DefPushButton 207, 9, 40, 14, "&Yes", TABSTOP
PushButton 207, 28, 40, 14, "&No", CANCEL TABSTOP
EndDialog
/* show lock dir */
if Choice = 1 then
{
NetID = "DirRestrict"
DRIVE_LOCK_CHECK
}
return (Choice)
endfunc
/*
ANSWER_CONFIG
Configures ANSWER.XWP for answer (host) mode.
Returns TRUE if configured, FALSE if not.
*/
function ANSWER_CONFIG returns boolean
/* Not configured - ask for service specific info */
if not exists(HomeDir + "\NORMAL.XWP") then
{
alert "Cannot locate Crosstalk directory", OK
return(FALSE)
}
if not exists(HomeDir + "\XWP20\ANSWER.XWP") then
{
alert "Cannot locate ANSWER.XWP entry", OK
return(FALSE)
}
load HomeDir + "\NORMAL.XWP"
savDevice = Device : SavFlow = Flow
savPort = Port : savSpeed = Speed
load HomeDir + "\XWP20\ANSWER.XWP"
Device = savDevice : Flow = SavFlow
Port = savPort : Speed = savSpeed
TheChoice = GET_PASSWORD
if TheChoice <> 1 then
{
ALERT "Configuration cancelled - open ANSWER.XWP to retry", OK
return(FALSE)
}
TheChoice = GET_DOWNLOADDIR
if Choice <> 1 then
{
ALERT "Configuration cancelled - open ANSWER.XWP to retry", OK
return(FALSE)
}
if not null(DownLoadDir) then
{
TheChoice = GET_LOCK_DIR
}
TheChoice = GET_PORT_SPEED ("Answer a call")
if TheChoice = 1 then
{
/* They said OK - show we're configured */
Description = "Crosstalk Answer mode"
Patience = 60
Mode = "Answer"
Terminal = "DCATTY"
Font = "XT Term"
return(TRUE)
}
else return(FALSE)
endfunc
/***************************************************************************
MAIN SCRIPT BEGINS HERE
***************************************************************************/
cls
trap on
/*
Check to see if the current phone book entry has been configured yet.
*/
if (Patience = 10) then
{
/* Not configured - ask for service specific info */
Configured = ANSWER_CONFIG
if not Configured then end
save "ANSWER"
TheChoice = ASK_CALL_NOW("Answer", "ANSWER")
if TheChoice = 2 then end
}
/*
Check for Directory restriction, and switch to DownloadDir.
*/
DRIVE_LOCK_CHECK
SET_DIRFIL FALSE
/*
Wait for the next incoming call (unless session is already online).
*/
if not online then {
go
if error then {
errmsg = "Error " + str(ErrClass) + " - " + str(ErrNo)
errmsg = errmsg + ". Unable to establish connection."
alert errmsg, OK
bye : end
}
if not online then bye : end
/*
Allow user to login.
*/
GoodLogin = CHECK_PASSWORD
if not GoodLogin then goto RESTART
}
/*
Process caller's commands.
*/
callerBye = FALSE
repeat
if not expert then ANSWER_MENU
ANSWER_COMMAND
CHECK
until callerBye = TRUE
/*
Restart the script.
*/
label RESTART
bye
SET_DIRFIL TRUE -- Reset original directory.
chain HomeDir + "\XWP20\ANSWER.XWS"
end