home *** CD-ROM | disk | FTP | other *** search
/ TestDrive Super Store 3.0 / TESTDRIVE_3.ISO / realizer / utility / fileview.rlz < prev    next >
Encoding:
Text File  |  1992-09-30  |  2.3 KB  |  96 lines

  1. '***********************************************************************
  2. '    FileView.rlz                              
  3. '
  4. '    Load any size file into Realizer windows
  5. '
  6. '    Copyright ⌐ 1991-1992 Computer Associates International, Inc.
  7. '    All rights reserved.
  8. '
  9. '***********************************************************************
  10.  
  11. PROC LogAppendStr (logNum, s)
  12. '
  13. '    FAST append string s to Log #logNum.
  14. '
  15. 'WARNING: Use this routine only if you're sure the carriage returns and linefeeds
  16. 'are all OK.  If you are sure, this routine is a LOT FASTER than:
  17. '    PRINT #logNum; s
  18. 'since the PRINT statement guarantees proper carriage return handling.
  19.  
  20.     LOCAL    oldLog, oldLen, hwt
  21.     LOCAL    WM_USER, EM_SETSEL, EM_REPLACESEL
  22.  
  23.     EXTERNAL "User" PROC SendMessage (word, word, word, pointer)
  24.     WM_USER = 1024
  25.     EM_SETSEL = (WM_USER + 1)
  26.     EM_REPLACESEL = (WM_USER + 18)
  27.  
  28.     oldLog = {LogQ(_Selected), 0}
  29.     IF NOT LogQ(_Exists; logNum) THEN
  30.         LogNew(logNum)
  31.     ELSE
  32.         LogSelect(logNum)
  33.     END IF
  34.     oldLen = LogQSize
  35.     hwt = LogQ(_Hwnd)
  36.     SendMessage(hwt, EM_SETSEL, 0, Pointer(32767*2^16 + 32767))
  37.     SendMessage(hwt, EM_REPLACESEL, 0, s)
  38.     IF oldLog[1] THEN
  39.         LogSelect(oldLog[1], oldLog[2])
  40.     END IF
  41.     IF oldLen + Len(s) <> LogQSize THEN
  42.         STOP USING "Error appending to Log.", 1
  43.     END IF
  44. END PROC
  45.  
  46. fn = StdOpen("*.*", "Select file")
  47. IF fn = "" THEN
  48.     EXIT PROGRAM
  49. END IF
  50.  
  51. FontNew(1; "Courier", 10)
  52.  
  53. title = Right$(fn, 12)
  54. LOOP
  55.     J = InStr(title, "\")
  56.     IF J THEN
  57.         title = Right$(title, Len(title) - J)
  58.     ELSE
  59.         EXIT LOOP
  60.     END IF
  61. END LOOP
  62.  
  63. perPart = 30000
  64. sz = FileQ(fn, _Size)
  65. nParts = (sz - 1) \ perPart + 1
  66. FileOpen(1, fn)
  67. part = 0
  68. WHILE NOT FileEOF(1)
  69.     part = part + 1
  70.     FileRead(1, s, perPart)
  71.     thisLog = LogQUnique()
  72.     IF nParts > 1 THEN
  73.         LogNew(thisLog; SPRINT("& (part P(0) of P(0))", title, part, nParts))
  74.         IF NOT FileEOF(1) THEN
  75.             ' put some characters back to end at a CRLF.
  76.             this = 0
  77.             nxt = MAX(Len(s) - 1000, 1)
  78.             WHILE nxt
  79.                 this = nxt
  80.                 nxt = InStr(s, CHR$(13) + CHR$(10), this + 1)
  81.             END WHILE
  82.             IF this THEN
  83.                 FileSeek(1, this + 1 - Len(s), _Cur)
  84.                 s = LEFT$(s, this + 1)
  85.             END IF
  86.         END IF
  87.     ELSE
  88.         LogNew(thisLog; title)
  89.     END IF
  90.     LogAppendStr(thisLog, s)
  91.     LogControl(_SetFont; 1)
  92.     LogControl(_Show)
  93. END WHILE
  94. FileClose(1)
  95. FontControl(_Close)
  96.