home *** CD-ROM | disk | FTP | other *** search
- *******************
-
- FUNCTION O_vars
-
- PARAMETERS _file, _bytes
-
- IF TYPE("_file") != "C" && Takes care of both wrong data type and
- RETURN(.F.) && no parameter passed.
- ELSEIF !FILE(_file) && And this is for a file NOT found.
- RETURN(.F.)
- ENDIF
-
- PRIVATE _fhandle, _line, _end, _char, _thevar, _theval, _bytes
-
- _bytes = IF( (TYPE("_bytes") != "N"), 1024, _bytes)
- _bytes = IF( (_bytes < 0), 1024, _bytes)
-
- _fhandle = FOPEN(_file)
- _line = ""
- _end = FSEEK(_fhandle, 0, 2)
- FSEEK(_fhandle, 0, 0)
- DO WHILE .T.
- _char = SPACE(_bytes)
- _exit = FREAD(_fhandle, @_char, _bytes) != _bytes
- DO WHILE !EMPTY(_char)
- _line = Parsing(@_char, CHR(13)+CHR(10) )
- IF "*" = SUBSTR(LTRIM(_line), 1, 1)
- * Ignore this line
- _line = ""
-
- ELSEIF "NOTE" = SUBSTR(UPPER(LTRIM(_line)), 1, 4)
- * Ignore this line
- _line = ""
-
- ELSEIF "&&" = SUBSTR(LTRIM(_line), 2, 4)
- * Ignore this line
- _line = ""
-
- ELSEIF "STORE "$UPPER(_line)
- *
- * also, you have to check for the ";" character
- *
- _theval = TRIM(LTRIM(STRTRAN(SUBSTR(UPPER(_line), 1, AT(" TO ", UPPER(_line))-1), "STORE", "")))
- _thevar = LTRIM(TRIM(SUBSTR(UPPER(_line), AT(" TO ", UPPER(_line))+4)))
- _line = "&_thevar. = &_theval."
-
- O_line(_line)
-
- ELSE
-
- O_line(_line)
-
- ENDIF
- ENDDO
-
- IF _exit
- _line = STRTRAN(_line, CHR(26), "")
- IF !EMPTY(_line)
- O_line(_line)
- ENDIF
- EXIT
- ENDIF
- ENDDO
- FCLOSE(_fhandle)
- RETURN(.T.)
-
- *******************
-
- PROCEDURE O_line
-
- PARAMETERS _line
-
- _thevar = LTRIM(TRIM(Parsing(@_line, "=")))
- _theval = LTRIM(TRIM(_line))
-
- IF EMPTY(_theval) .AND. !EMPTY(_thevar)
- *
- * test to see if an array
- *
- IF "["$_thevar .AND. "]"$_thevar
- _tempvar = _thevar
- Parsing(@_tempvar, "[")
- _subscr = VAL(Parsing(@_tempvar, "]"))
- IF !EMPTY(_subscr)
- _isarray = Parsing(@_thevar, "[")
- PUBLIC &_isarray.[_subscr]
- ENDIF
- *
- * See if it is a function
- *
- ELSEIF "("$_thevar .AND. ")"$_thevar
-
- IF TYPE(_thevar) == "UI" && The function exists!
- * Perform it!
- Op(&_thevar.)
- ENDIF
-
- ENDIF
- ELSEIF EMPTY(_thevar) .OR. EMPTY(_line)
- * either side is empty
- ELSEIF (TYPE(_theval) == "U") .OR. (TYPE(_theval) == "UE")
- IF "("$_theval .AND. ")"$_theval
- PUBLIC &_thevar.
- &_thevar. = "Missing External"
- ENDIF
- * Missing second quote or bad format..
- ELSE
-
- * Assign the variable
- PUBLIC &_thevar.
- &_thevar. = &_theval.
-
- ENDIF
-
- * End of File
-