WeirdScience
Programmer
Hi Gurus,
We have a foxpro 8.0 application which reads a sort of Settings dbf for several public/global settings.
We heard from several users that a lot of errors related to this settings file are occuring in the system.
Now we've checked on the Windows 'Open Files' tab that this settings file is not closed correctly or immediately.
Basically this is the code for one of the functions which set these global settings.
Anyone with a suggestion?
Regards,
Weird Science
We have a foxpro 8.0 application which reads a sort of Settings dbf for several public/global settings.
We heard from several users that a lot of errors related to this settings file are occuring in the system.
Now we've checked on the Windows 'Open Files' tab that this settings file is not closed correctly or immediately.
Basically this is the code for one of the functions which set these global settings.
Anyone with a suggestion?
Code:
FUNCTION l1_path
PARAMETER lKey
PRIVATE lArea, sFullPath
sFullPath = LEFT(SYS(16,0), RAT("\", SYS(16,0))) + "path.dbf"
lArea = ALIAS()
* Check whether the PATH.DBF table is in the current directory
IF NOT FILE(sFullPath)
R=l1_beep("error")
WAIT WINDOW "FILE ERROR : PATH.DBF NOT FOUND IN CURRENT DIRECTORY !"
QUIT
ENDIF
* Open the PATH table in the next available workspace
TRY
USE &sFullPath ALIAS dbpath SHARED IN 0
CATCH
TRY
USE &sFullPath ALIAS dbpath SHARED IN 0
CATCH
WAIT WINDOW "Error opening PATH.DBF [l1_path]" NOWAIT
USE &sFullPath ALIAS dbpath SHARED IN 0
ENDTRY
ENDTRY
SELECT dbpath
* Select the value needed using the key used
LOCATE FOR ALLTRIM(UPPER(dbpath.key)) = ALLTRIM(UPPER(lKey))
IF NOT FOUND()
R=l1_beep("error")
WAIT WINDOW "PATH ERROR : KEY '" + lKey +"' NOT FOUND !"
SELECT dbpath
USE
QUIT
ENDIF
* Store path in memory and close the table
lValue = dbpath.Value
SELECT dbpath
USE
* Check whether the locate came up with a value at all
IF Empty(Alltrim(lValue))
R=l1_beep("error")
WAIT WINDOW "PATH ERROR : KEY '" + lKey +"' HAS NO VALUE !"
QUIT
ENDIF
* Check whether PATH returned exists
* IF NOT FILE(ALLTRIM(lValue) + "\nul")
* R=l1_beep("error")
* WAIT WINDOW "PATH ERROR : " + UPPER(lKey) + " '" + ALLTRIM(lValue) + "' NOT FOUND !"
* QUIT
* ENDIF
IF(!EMPTY(lArea))
SELECT &lArea
ENDIF
lKey=ALLTRIM(lValue)
RETURN lKey
Regards,
Weird Science