home *** CD-ROM | disk | FTP | other *** search
/ Chip: Windows 95 / WIN95_CD.ISO / sharewar / internet / qmodem / scripts.z / HOSTFILE.QSC < prev    next >
Encoding:
Text File  |  1995-07-20  |  6.1 KB  |  220 lines

  1. ' File area routines for host mode.
  2. '
  3. ' DO NOT COMPILE THIS FILE BY ITSELF!
  4. '
  5. ' This file is a part of the complete HOST.QSC and will not compile
  6. ' alone.  To recompile the host scripts, select Scripts/Compile from
  7. ' the QmodemPro for Windows menu and select HOST.QSC in the "Compile
  8. ' script" dialog box.  This file will automatically be compiled as
  9. ' part of the full script.
  10.  
  11. function GetProtocol as integer
  12.   dim s as string
  13.   if not DisplayFile(ProtocolFileName) then
  14.     send #Port, "Select a file transfer protocol:"
  15.     send #Port,
  16.     send #Port, "[A] Ascii  [X] Xmodem   [C] Xmodem/CRC  [1] Xmodem/1K  [F] Xmodem/1KG"
  17.     send #Port, "[Y] Ymodem [G] Ymodem/G [Z] Zmodem      [K] Kermit"
  18.   end if
  19.   send #Port,
  20.   s = GetLine("Protocol: ")
  21.   select case OemUpper(left(s, 1))
  22.     case "A"
  23.       GetProtocol = ASCII
  24.     case "X"
  25.       GetProtocol = Xmodem
  26.     case "C"
  27.       GetProtocol = XmodemCRC
  28.     case "1"
  29.       GetProtocol = Xmodem1K
  30.     case "F"
  31.       GetProtocol = Xmodem1KG
  32.     case "Y"
  33.       GetProtocol = Ymodem
  34.     case "G"
  35.       GetProtocol = YmodemG
  36.     case "Z"
  37.       GetProtocol = Zmodem
  38.     case "K"
  39.       GetProtocol = Kermit
  40.     case else
  41.       GetProtocol = -1
  42.   end select
  43. end function
  44.  
  45. function ProtocolName(prot as integer) as string
  46.   select case prot
  47.     case ASCII
  48.       ProtocolName = "ASCII"
  49.     case Xmodem
  50.       ProtocolName = "Xmodem"
  51.     case XmodemCRC
  52.       ProtocolName = "Xmodem/CRC"
  53.     case Xmodem1K
  54.       ProtocolName = "Xmodem/1K"
  55.     case Xmodem1KG
  56.       ProtocolName = "Xmodem/1KG"
  57.     case Ymodem
  58.       ProtocolName = "Ymodem"
  59.     case YmodemG
  60.       ProtocolName = "Ymodem/G"
  61.     case Zmodem
  62.       ProtocolName = "Zmodem"
  63.     case Kermit
  64.       ProtocolName = "Kermit"
  65.   end select
  66. end function
  67.  
  68. ' List files
  69.  
  70. sub ListFiles
  71.   dim result as integer, count as integer, total as integer, sr as SearchRec
  72.   if Setup.dlpath = "" then
  73.     send #Port,
  74.     send #Port, "Sorry, downloads are not available."
  75.     send #Port,
  76.     exit sub
  77.   end if
  78.   total = 0
  79.   count = 0
  80.   result = FindFirst(AddBackSlash(Setup.dlpath)+"*.*", sr)
  81.   do while result = 0 and not CallerHungUp
  82.     dim i as integer
  83.     i = instr(sr.filename, ".")
  84.     if i > 0 then
  85.       send #Port, left(sr.filename, i-1); tab(10); right(sr.filename, len(sr.filename)-i); tab(14);
  86.     else
  87.       send #Port, sr.filename; tab(14);
  88.     end if
  89.     send #Port, space(11-len(str(sr.filesize))); sr.filesize;
  90.     send #Port, FormatDate(" mm-dd-yy", sr.LastWriteTime);
  91.     send #Port, FormatTime(" hh:mm", sr.LastWriteTime);
  92.     send #Port,
  93.     total = total + 1
  94.     count = count + 1
  95.     if count >= 24 then
  96.       if OemUpper(GetLine("-Pause- [C]ontinue, [S]top? ", 1)) = "S" then
  97.         exit do
  98.       end if
  99.       count = 0
  100.     end if
  101.     result = FindNext(sr)
  102.   loop
  103.   send #Port,
  104.   send #Port, total; " file(s) available"
  105.   send #Port,
  106.   GetLine "Press Enter to continue? "
  107. end sub
  108.  
  109. ' Download file
  110.  
  111. sub DownloadFile
  112.   dim fnames as string, protocol as integer, count as integer
  113.   dim onefile as integer
  114.   if Setup.dlpath = "" then
  115.     send #Port,
  116.     send #Port, "Sorry, downloads are not available."
  117.     send #Port,
  118.     exit sub
  119.   end if
  120.   protocol = GetProtocol()
  121.   if protocol < 0 then exit sub
  122.   onefile = protocol < Ymodem
  123.   do
  124.     dim s as string
  125.     s = GetLine("File to download: ")
  126.     if CallerHungUp then
  127.       exit sub
  128.     end if
  129.     if s = "" then exit do
  130.     send #Port,
  131.     if Setup.sysopanypath = 0 or User.Level = 0 then
  132.       s = AddBackSlash(Setup.dlpath)+JustFilename(s)
  133.     elseif instr(s, "\") = 0 then
  134.       s = AddBackSlash(Setup.dlpath)+JustFilename(s)
  135.     end if
  136.     dim sr as SearchRec
  137.     if findfirst(s, sr) = 0 then
  138.       do
  139.         if len(fnames) > 0 then
  140.           fnames = fnames + " "
  141.         end if
  142.         fnames = fnames + AddBackSlash(JustPathName(s)) + sr.FileName
  143.         count = count + 1
  144.         dim i as integer
  145.         i = instr(sr.filename, ".")
  146.         if i > 0 then
  147.           send #Port, left(sr.filename, i-1); tab(10); right(sr.filename, len(sr.filename)-i); tab(14);
  148.         else
  149.           send #Port, sr.filename; tab(14);
  150.         end if
  151.         send #Port, space(11-len(str(sr.filesize))); sr.filesize;
  152.         send #Port, FormatDate(" mm-dd-yy", sr.LastWriteTime);
  153.         send #Port, FormatTime(" HH:mmt", sr.LastWriteTime);
  154.         send #Port,
  155.       loop until (onefile and count = 1) or findnext(sr) <> 0
  156.       send #Port,
  157.     else
  158.       send #Port, "The file "; s; " could not be found on disk."
  159.     end if
  160.   loop until onefile and count = 1
  161.   if count > 0 then
  162.     if Local then
  163.       send #Port, "The following files would be transferred if you were not on locally:"
  164.       send #Port, fnames
  165.     else
  166.       send #Port,
  167.       send #Port, "Begin your "; ProtocolName(protocol); " download of ";
  168.       if count = 1 then
  169.         send #Port, fnames;
  170.       else
  171.         send #Port, count, " files"
  172.       end if
  173.       send #Port, " now"
  174.       delay 1
  175.       sendfile fnames, protocol
  176.     end if
  177.   else
  178.     send #Port, "No files selected."
  179.   end if
  180. end sub
  181.  
  182. ' Upload file
  183.  
  184. sub UploadFile
  185.   dim fname as string, protocol as integer
  186.   if Setup.ulpath = "" then
  187.     send #Port,
  188.     send #Port, "Sorry, uploads are not available."
  189.     send #Port,
  190.     exit sub
  191.   end if
  192.   if Local then
  193.     send #Port, "Uploads not available when logged on locally"
  194.     exit sub
  195.   end if
  196.   protocol = GetProtocol()
  197.   if protocol = 0 or CallerHungUp then exit sub
  198.   send #Port,
  199.   fname = "your file"
  200.   if protocol < Ymodem then
  201.     fname = GetLine("File to upload: ")
  202.     send #Port,
  203.     if fname = "" or CallerHungUp then exit sub
  204.     fname = AddBackSlash(Setup.ulpath)+JustFilename(fname)
  205.     if exists(fname) then
  206.       send #Port, "The file "; fname; " already exists on disk."
  207.       exit sub
  208.     end if
  209.     send #Port, "Begin your "; ProtocolName(protocol); " upload of "; fname; " now"
  210.   else
  211.     fname = Setup.ulpath
  212.     send #Port, "Begin your "; ProtocolName(protocol); " upload of your file now"
  213.   end if
  214.   delay 1
  215.   receivefile fname, protocol
  216. end sub
  217.  
  218.  
  219.  
  220.