home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a075 / 1.img / TOOLKIT1.EXE / SST341.PRG < prev    next >
Encoding:
Text File  |  1989-08-08  |  1.8 KB  |  80 lines

  1. ********************
  2.  
  3. FUNCTION O_asize    && Sst341.prg
  4.  
  5.    PARAMETERS _ofile, _array, _bytes
  6.  
  7.    PRIVATE _cnt, _fh, _bytes
  8.  
  9.    IF EMPTY(PCOUNT())
  10.       RETURN(0)
  11.    ELSEIF PCOUNT() = 1
  12.       IF !FILE(_ofile)
  13.          RETURN(0)
  14.       ENDIF
  15.    ELSEIF PCOUNT() = 2
  16.       IF !FILE(_ofile)
  17.          RETURN(0)
  18.       ENDIF
  19.       IF TYPE("_array") != "A"
  20.          RETURN(0)
  21.       ENDIF
  22.    ENDIF
  23.  
  24.    _bytes = IF( (TYPE("_bytes") != "N"), 1024, _bytes)
  25.    _bytes = IF( (_bytes < 0), _1024, _bytes)
  26.  
  27.    _fh = FOPEN(_ofile)
  28.    _end = FSEEK(_fh, 0, 2)
  29.    _line = ""
  30.    _count = 0
  31.    FSEEK(_fh, 0, 0)
  32.    DO WHILE .T.
  33.       _char = SPACE(_bytes)
  34.       _exit = FREAD(_fh, @_char, _bytes ) != _bytes
  35.       _char = _line + _char
  36.       DO WHILE !EMPTY(_char)
  37.          _line = Parsing(@_char, CHR(13)+CHR(10) )
  38.          IF LEFT(LTRIM(TRIM(_line)), 1) = "*"   
  39.             _line = ""
  40.  
  41.          ELSEIF "NOTE" = SUBSTR(UPPER(LTRIM(_line)),1,4)
  42.             _line = ""
  43.  
  44.          ELSEIF "&&" = SUBSTR(LTRIM(_line), 2, 4)
  45.             _line = ""
  46.  
  47.          ELSEIF EMPTY(_line)
  48.             _line = ""
  49.  
  50.          ELSE
  51.             IF !EMPTY(_char)
  52.                _count = _count + 1
  53.                IF PCOUNT() = 2
  54.                   _array[_count] = _line
  55.                ENDIF
  56.             ENDIF
  57.          ENDIF
  58.       ENDDO
  59.       *
  60.       * if _char is empty and _line is NOT, then _line
  61.       * must be added to char at the top of the loop
  62.       *
  63.       IF _exit
  64.          * replace EOF marker with null byte
  65.          _line = STRTRAN(_line, CHR(26), "")
  66.          * if there are still characters, write it out.
  67.          IF !EMPTY(_line)
  68.             _count = _count + 1
  69.             IF PCOUNT() = 2
  70.                _array[_count] = _line
  71.             ENDIF
  72.          ENDIF
  73.          EXIT
  74.       ENDIF
  75.    ENDDO
  76.    FCLOSE(_fh)
  77.    RETURN(_count)
  78.  
  79. * End of File
  80.