Board index » delphi » Check alias and path

Check alias and path

Hi,

Within my application the user may enter :
- name of the alias he wants to use for the database
- alias path
Those items will be stored into a .ini file. The database himself has a
default name,
lets say PHONE.DB. Every time the application is started, the entries
will be
readed out of the .ini file and will be used in the application.

There one check I have to do...and thats the followin one:
1. read the aliasname out of the .ini file (DONE...no problem
2. read the path of the aliasname out of the .ini file (DONE...no
problem
3. check if alias exists in idapi.cfg (PROBLEM)
4. check if alias path exists  (PROBLEM)
5. check if the phone.db can be found on this location (PROBLEM)

If point 3,4,5 are all true, the application may be lauched, otherwise
terminate
I did check out the BDE help file and also the borland site...but I
can't figure
it out....who can help.

Greetings Peter

 

Re:Check alias and path


"Peter van Mierlo" <p.van.mie...@eindhoven.nl> wrote in message
news:39DCA2F6.AFBBCF91@eindhoven.nl...

Quote
> There one check I have to do...and thats the followin one:
> 1. read the aliasname out of the .ini file (DONE...no problem
> 2. read the path of the aliasname out of the .ini file (DONE...no
> problem
> 3. check if alias exists in idapi.cfg (PROBLEM)
> 4. check if alias path exists  (PROBLEM)
> 5. check if the phone.db can be found on this location (PROBLEM)

May I suggest not using an actual alias. Since you are already storing the
path in an INI file, it can be placed directly into the DatabaseName
property of a TDatabase. You don't need to create an alias that way and your
tables can all point to that TDatabase. Testing for file existence is fairly
easy.

function DoesFileExist(path, filename: string): boolean;
begin
    if path[length(path)] <> '\' then
        path := path  + '\';
    result := FileExists(path + filename);
end;

HTH
Woody

Re:Check alias and path


Hi,
To check if alias exist write this:
    if Session1.IsAlias('Name of Alias') then Label1.Caption:='Got it';

Other Threads