home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / TE2HOST.ZIP / TYPEFILE.SCR < prev    next >
Text File  |  1990-12-27  |  2KB  |  87 lines

  1. ;; --------------------------------------------------------------------------
  2. ;;
  3. ;; TypeFile.scr -- Host mode script suite for TE/2
  4. ;;                 Copyright 1990, Oberon Software, All rights reserved
  5. ;;
  6. ;; --------------------------------------------------------------------------
  7.  
  8. global string  CmdStack
  9. global string  FileSpec
  10. global string  DfltSpec
  11. global integer WatchUser
  12.  
  13. integer FileHandle
  14. string  buffer
  15. integer count
  16. integer KeyIn
  17.  
  18.   ;; ------------------------------------------------------------------------
  19.   ;; Display a text file at the remote.  This function is also used
  20.   ;;  internally; if "CmdStack" is not empty, we skip the user prompt
  21.   ;;  and go right to the file.  As in subroutine DiskDirectory, this
  22.   ;;  does not now, but probably should, limit lower priv users to the
  23.   ;;  current directory.
  24.  
  25. subroutine TypeFile
  26.  
  27.   if strlen(CmdStack) == 0
  28.     transmit("^M^JType a File")
  29.     DfltSpec = ""
  30.     run("getfspec.scr")
  31.   else
  32.     FileSpec = CmdStack
  33.     CmdStack = ""
  34.   endif
  35.  
  36.   if strlen(FileSpec) > 0
  37.     if strstr(FileSpec, "*") or strstr(FileSpec, "?")
  38.       transmit("^M^JSorry. This function does not handle wildcards^M^J")
  39.  
  40.     else
  41.       FileHandle = fopen(FileSpec, "r")
  42.       if (FileHandle & 0xffff)
  43.         termecho(FALSE)
  44.         localecho(FALSE)
  45.         transmit("^[[2J")
  46.         message("^M^JUser is typing file [%s]", FileSpec)
  47.         buffer = fgets(FileHandle)
  48.         count = 1
  49.         do while strlen(buffer)
  50.           transmit("%s^M", buffer)
  51.           count = count + 1
  52.           if count == ScrLength
  53.             transmit("Press any key to continue...")
  54.             KeyIn = rgetc(30, 1)
  55.             if KeyIn == 27 or timedout
  56.               transmit("^M^J")
  57.               break
  58.             endif
  59.             count = 1
  60.             transmit("^[[2J")
  61.           endif
  62.           buffer = fgets(FileHandle)
  63.         loop
  64.         fclose(FileHandle)
  65.         if WatchUser
  66.           termecho(TRUE)
  67.           localecho(TRUE)
  68.         endif
  69.  
  70.       else
  71.         transmit("^M^JCannot open file [%s]^M^J", FileSpec)
  72.       endif
  73.  
  74.     endif
  75.  
  76.     transmit("^M^JPress any key to continue...")
  77.     rgetc(30, 1)
  78.   endif
  79.  
  80. endsub
  81.  
  82.  
  83. program
  84.   gosub TypeFile
  85.   end
  86.  
  87.