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

  1. *******************
  2.  
  3. FUNCTION O_vars
  4.  
  5.    PARAMETERS _file, _bytes
  6.  
  7.    IF TYPE("_file") != "C"   && Takes care of both wrong data type and
  8.       RETURN(.F.)            && no parameter passed.
  9.    ELSEIF !FILE(_file)       && And this is for a file NOT found.
  10.       RETURN(.F.)
  11.    ENDIF
  12.  
  13.    PRIVATE _fhandle, _line, _end, _char, _thevar, _theval, _bytes
  14.  
  15.    _bytes = IF( (TYPE("_bytes") != "N"), 1024, _bytes)
  16.    _bytes = IF( (_bytes < 0), 1024, _bytes)
  17.  
  18.    _fhandle = FOPEN(_file)
  19.    _line = ""
  20.    _end = FSEEK(_fhandle, 0, 2)
  21.    FSEEK(_fhandle, 0, 0)
  22.    DO WHILE .T.
  23.       _char = SPACE(_bytes)
  24.       _exit = FREAD(_fhandle, @_char, _bytes) != _bytes
  25.       DO WHILE !EMPTY(_char)
  26.          _line = Parsing(@_char, CHR(13)+CHR(10) )
  27.          IF "*" = SUBSTR(LTRIM(_line), 1, 1)
  28.             * Ignore this line
  29.             _line = ""
  30.  
  31.          ELSEIF "NOTE" = SUBSTR(UPPER(LTRIM(_line)), 1, 4)
  32.             * Ignore this line
  33.             _line = ""
  34.  
  35.          ELSEIF "&&" = SUBSTR(LTRIM(_line), 2, 4)
  36.             * Ignore this line
  37.             _line = ""
  38.  
  39.          ELSEIF "STORE "$UPPER(_line)
  40.             *
  41.             * also, you have to check for the ";" character
  42.             *
  43.             _theval = TRIM(LTRIM(STRTRAN(SUBSTR(UPPER(_line), 1, AT(" TO ", UPPER(_line))-1), "STORE", "")))
  44.             _thevar = LTRIM(TRIM(SUBSTR(UPPER(_line), AT(" TO ", UPPER(_line))+4)))
  45.             _line = "&_thevar. = &_theval."
  46.  
  47.             O_line(_line)
  48.  
  49.          ELSE
  50.  
  51.             O_line(_line)
  52.  
  53.          ENDIF
  54.       ENDDO
  55.  
  56.       IF _exit
  57.          _line = STRTRAN(_line, CHR(26), "")
  58.          IF !EMPTY(_line)
  59.             O_line(_line)
  60.          ENDIF
  61.          EXIT
  62.       ENDIF
  63.    ENDDO
  64.    FCLOSE(_fhandle)
  65.    RETURN(.T.)
  66.  
  67. *******************
  68.  
  69. PROCEDURE O_line
  70.  
  71.    PARAMETERS _line
  72.  
  73.    _thevar = LTRIM(TRIM(Parsing(@_line, "=")))
  74.    _theval = LTRIM(TRIM(_line))
  75.  
  76.    IF EMPTY(_theval) .AND. !EMPTY(_thevar)
  77.       *
  78.       * test to see if an array
  79.       *
  80.       IF "["$_thevar .AND. "]"$_thevar
  81.          _tempvar = _thevar
  82.          Parsing(@_tempvar, "[")
  83.          _subscr = VAL(Parsing(@_tempvar, "]"))
  84.          IF !EMPTY(_subscr)
  85.             _isarray = Parsing(@_thevar, "[")
  86.             PUBLIC &_isarray.[_subscr]
  87.          ENDIF
  88.       *
  89.       * See if it is a function
  90.       *
  91.       ELSEIF "("$_thevar .AND. ")"$_thevar
  92.  
  93.          IF TYPE(_thevar) == "UI"  && The function exists!
  94.             * Perform it!
  95.             Op(&_thevar.)
  96.          ENDIF
  97.  
  98.       ENDIF
  99.    ELSEIF EMPTY(_thevar) .OR. EMPTY(_line)
  100.       * either side is empty
  101.    ELSEIF (TYPE(_theval) == "U") .OR. (TYPE(_theval) == "UE")
  102.       IF "("$_theval .AND. ")"$_theval
  103.          PUBLIC &_thevar.      
  104.          &_thevar. = "Missing External"
  105.       ENDIF
  106.       * Missing second quote or bad format..
  107.    ELSE
  108.  
  109.       * Assign the variable
  110.       PUBLIC &_thevar.      
  111.       &_thevar. = &_theval.
  112.  
  113.    ENDIF
  114.  
  115. * End of File
  116.  
  117.