home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CICA 1997 February
/
cicawindowscollection199702-1.iso
/
disc1
/
comm
/
q95demo.exe
/
SCRIPTS.Z
/
HOSTFILE.QSC
< prev
next >
Wrap
Text File
|
1995-11-08
|
7KB
|
225 lines
' File area routines for host mode.
'
' DO NOT COMPILE THIS FILE BY ITSELF!
'
' This file is a part of the complete HOST.QSC and will not compile
' alone. To recompile the host scripts, select Scripts/Compile from
' the QmodemPro for Windows menu and select HOST.QSC in the "Compile
' script" dialog box. This file will automatically be compiled as
' part of the full script.
function GetProtocol as integer
dim s as string
if not DisplayFile(ProtocolFileName) then
send #Port, "Select a file transfer protocol:"
send #Port,
send #Port, "[A] Ascii [X] Xmodem [C] Xmodem/CRC [1] Xmodem/1K [F] Xmodem/1KG"
send #Port, "[Y] Ymodem [G] Ymodem/G [Z] Zmodem [K] Kermit"
end if
send #Port,
s = GetLine("Protocol: ")
select case OemUpper(left(s, 1))
case "A"
GetProtocol = ASCII
case "X"
GetProtocol = Xmodem
case "C"
GetProtocol = XmodemCRC
case "1"
GetProtocol = Xmodem1K
case "F"
GetProtocol = Xmodem1KG
case "Y"
GetProtocol = Ymodem
case "G"
GetProtocol = YmodemG
case "Z"
GetProtocol = Zmodem
case "K"
GetProtocol = Kermit
case else
GetProtocol = -1
end select
end function
function ProtocolName(prot as integer) as string
select case prot
case ASCII
ProtocolName = "ASCII"
case Xmodem
ProtocolName = "Xmodem"
case XmodemCRC
ProtocolName = "Xmodem/CRC"
case Xmodem1K
ProtocolName = "Xmodem/1K"
case Xmodem1KG
ProtocolName = "Xmodem/1KG"
case Ymodem
ProtocolName = "Ymodem"
case YmodemG
ProtocolName = "Ymodem/G"
case Zmodem
ProtocolName = "Zmodem"
case Kermit
ProtocolName = "Kermit"
end select
end function
' List files
sub ListFiles
dim result as integer, count as integer, total as integer, sr as SearchRec
if Setup.dlpath = "" then
send #Port,
send #Port, "Sorry, downloads are not available."
send #Port,
exit sub
end if
total = 0
count = 0
print AddBackSlash(Setup.dlpath)+"*.*"
result = FindFirst(AddBackSlash(Setup.dlpath)+"*.*", sr)
do while result = 0 and not CallerHungUp
if sr.AlternateFileName = "" then
sr.AlternateFileName = sr.FileName
end if
dim i as integer
i = instr(sr.Alternatefilename, ".")
if i > 0 then
send #Port, left(sr.Alternatefilename, i-1); tab(10); right(sr.Alternatefilename, len(sr.Alternatefilename)-i); tab(14);
else
send #Port, sr.Alternatefilename; tab(14);
end if
send #Port, space(11-len(str(sr.filesize))); sr.filesize;
send #Port, FormatDate(" MM-dd-yy", sr.LastWriteTime);
send #Port, FormatTime(" hh:mmt ", sr.LastWriteTime);
send #Port, sr.FileName
total = total + 1
count = count + 1
if count >= 24 then
if OemUpper(GetLine("-Pause- [C]ontinue, [S]top? ", 1)) = "S" then
exit do
end if
count = 0
end if
result = FindNext(sr)
loop
send #Port,
send #Port, total; " file(s) available"
send #Port,
GetLine "Press Enter to continue? "
end sub
' Download file
sub DownloadFile
dim fnames as string, protocol as integer, count as integer
dim onefile as integer
if Setup.dlpath = "" then
send #Port,
send #Port, "Sorry, downloads are not available."
send #Port,
exit sub
end if
protocol = GetProtocol()
if protocol < 0 then exit sub
onefile = protocol < Ymodem
do
dim s as string
s = GetLine("File to download: ")
if CallerHungUp then
exit sub
end if
if s = "" then exit do
send #Port,
if Setup.sysopanypath = 0 or User.Level = 0 then
s = AddBackSlash(Setup.dlpath)+JustFilename(s)
elseif instr(s, "\") = 0 then
s = AddBackSlash(Setup.dlpath)+JustFilename(s)
end if
dim sr as SearchRec
if findfirst(s, sr) = 0 then
do
if len(fnames) > 0 then
fnames = fnames + " "
end if
fnames = fnames + """" + AddBackSlash(JustPathName(s)) + sr.FileName + """"
count = count + 1
if sr.AlternateFileName = "" then
sr.AlternateFileName = sr.FileName
end if
dim i as integer
i = instr(sr.Alternatefilename, ".")
if i > 0 then
send #Port, left(sr.Alternatefilename, i-1); tab(10); right(sr.Alternatefilename, len(sr.Alternatefilename)-i); tab(14);
else
send #Port, sr.Alternatefilename; tab(14);
end if
send #Port, space(11-len(str(sr.filesize))); sr.filesize;
send #Port, FormatDate(" MM-dd-yy", sr.LastWriteTime);
send #Port, FormatTime(" HH:mmt ", sr.LastWriteTime);
send #Port, sr.FileName
loop until (onefile and count = 1) or findnext(sr) <> 0
send #Port,
else
send #Port, "The file "; s; " could not be found on disk."
end if
loop until onefile and count = 1
if count > 0 then
if Local then
send #Port, "The following files would be transferred if you were not on locally:"
send #Port, fnames
else
send #Port,
send #Port, "Begin your "; ProtocolName(protocol); " download of ";
if count = 1 then
send #Port, fnames;
else
send #Port, count, " files"
end if
send #Port, " now"
delay 1
sendfile fnames, protocol
end if
else
send #Port, "No files selected."
end if
end sub
' Upload file
sub UploadFile
dim fname as string, protocol as integer
if Setup.ulpath = "" then
send #Port,
send #Port, "Sorry, uploads are not available."
send #Port,
exit sub
end if
if Local then
send #Port, "Uploads not available when logged on locally"
exit sub
end if
protocol = GetProtocol()
if protocol = 0 or CallerHungUp then exit sub
send #Port,
fname = "your file"
if protocol < Ymodem then
fname = GetLine("File to upload: ")
send #Port,
if fname = "" or CallerHungUp then exit sub
fname = AddBackSlash(Setup.ulpath)+JustFilename(fname)
if exists(fname) then
send #Port, "The file "; fname; " already exists on disk."
exit sub
end if
send #Port, "Begin your "; ProtocolName(protocol); " upload of "; fname; " now"
else
fname = Setup.ulpath
send #Port, "Begin your "; ProtocolName(protocol); " upload of your file now"
end if
delay 1
receivefile fname, protocol
end sub