| View previous topic :: View next topic |
| Author |
Message |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Wed Feb 19, 2003 9:54 pm Post subject: INI file reading problem |
|
|
I'm having some trouble reading an INI file.
Here is the experimental INI file I'm using:
[app]
name=Test app
version=1.0
and here's the code I'm testing that don't work:
| Code: | INIFILE OPEN,settings.ini
%%name = @INIREAD(app,name)
%%version = @INIREAD(app,version)
info Name: %%name@cr()V%%version |
Am I doing something wrong?
I only get empty vars back.  _________________
 |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Wed Feb 19, 2003 10:08 pm Post subject: |
|
|
You must make sure your program or dsc file is located in the same directory as the ini file and then use:
Where @path(%0) returns the current directory !
| Code: | INIFILE OPEN,@path(%0)settings.ini
%%name = @INIREAD(app,name)
%%version = @INIREAD(app,version)
info Name: %%name@cr()V%%version |
or use
| Code: |
INIFILE OPEN,c:\whereever\the\file\is\stored\settings.ini
%%name = @INIREAD(app,name)
%%version = @INIREAD(app,version)
info Name: %%name@cr()V%%version
|
nathan |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Feb 19, 2003 10:12 pm Post subject: |
|
|
As Nathan mentioned it would be best to place the INI file in the same
directory as the program. The variable %0 contains the whole path to your
executable/script. When you use @path(%0) it gets just the path to your
executable. If the current system directory (can be obtained by using
@curdir()) is changed, then you won't find your INI file if you don't
specify the location to it. _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Wed Feb 19, 2003 10:12 pm Post subject: |
|
|
Aaa great. Thanks Rubes_sw.
Wonder why that isn't stated in the help file...
I find that there is alot of things that is lacking from the documention of VDS. _________________
 |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Thu Feb 20, 2003 5:03 pm Post subject: |
|
|
| Well, I don't think it isn't told wrong in the help file, because most people understand that "inifile.ini" must be in the same directory as the program... |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 5:29 pm Post subject: |
|
|
Well, I tried this
INIFILE OPEN,inifile.ini
But that didn't work.
I have to specify the full path to the ini. _________________
 |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Feb 20, 2003 5:38 pm Post subject: |
|
|
Loading any external files such as BMPs or INIs will need a path or else I believe VDS looks in the Windows folders and then in the folder your program was ran from. VDS probably found a settings.ini file in one of the Windows folders and tried using that one.
So, to make things easier for yourself and the user, always specify the path that your file is in. That's something most of us have learned the hard way.  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 5:45 pm Post subject: |
|
|
OK, thanks for the tip.
I'll do some experimenting with this. _________________
 |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Thu Feb 20, 2003 6:13 pm Post subject: |
|
|
FYI - I'm pretty sure Windows will look in the root windows folder or current path (by default) for INI files if no path is specified.
moke |
|
| Back to top |
|
 |
GeoTrail Valued Contributor


Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Feb 20, 2003 6:31 pm Post subject: |
|
|
OK, thanks  _________________
 |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Tue Feb 25, 2003 11:29 pm Post subject: |
|
|
Try INIFILE OPEN,.\inifile.ini
| GeoTrail wrote: | Well, I tried this
INIFILE OPEN,inifile.ini
But that didn't work.
I have to specify the full path to the ini. |
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Feb 27, 2003 10:33 am Post subject: |
|
|
| Tommy wrote: | | Try INIFILE OPEN,.\inifile.ini |
Hmmm. Interesting. I didn't know this syntax (dot-slash) was working in VDS. I guess that should
mean that e.g. this should work also:
Base directory:
LIST FILELIST,1,.\*.*
One level up:
LIST FILELIST,1,..\*.*
Two levels up:
LIST FILELIST,1,..\..\*.*
Root dir:
LIST FILELIST,1,\*.*
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
|