>Hi all
>
>When i create an application i start to run it usin a program
>MAIN.PRG.
>i this program i use a line like this below(to search the files)
>
>set path to C :\TABLES ;\ROUTINES :\ETC :
>
>but wath happend when a user urun the program from some unit like d:
>or G: (or wathever) it appear an error in the application.
>
>what is the better Tip to path the rute of the files to take that any user run it whatever her unit?
>
The easiest route is to store the path in an initialization location that you can always find, whether the Windows Registry at a known key, or in a file whose location is fixed and known (ie the file will always be C:\MYApp\MyCONFIG.INI) or whose location can be derived based on a path known at startup (ie MyConfig.INI is always in the same directory as the .EXE, so that the path returned by SYS(16,1) can be used as a basis, or is always in the startup directory, so that the program can find it as MyConfig.INI before the path assignments are made.)
A simple example, based on finding a file called MyPath.TXT in the startup directory:
LOCAL nFH, cMyPathAssignment
nFH = FOPEN('MyConfig.TXT')
IF nFH # -1
* FOPEN() returns -1 if the file can't be opened for (almost) any reason
* I'll include the startup path as an absolute reference, and concatenate
* this with the first line of the file I opened above. YMMV.
cMyPathAssignment = FULLPATH(SYS(2003)) + ';' + FGETS(nFH)
=FCLOSE(nFH)
* I assume that the first line of MyConfig.TXT contains the paths you want separated by semicolon
SET PATH TO &cMyPathAssignment
ELSE
* The file either doesn't exist, or can't be read, so do something here to set up some defaults
* or cancel the app with an error. Whatever.
ENDIF
You can get as sophisticated as you like; .INI files, registry entries or any other store at a known location accessed via a common method will work equally well for this sort of situation. The key is to be able to find the information using a consistent method, and to make sure that the data is written there before you need to access it.
Ed