forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


INI file reading problem

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 9:54 pm    Post subject: INI file reading problem Reply with quote

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. Crying or Very sad

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Rubes_sw
Valued Contributor
Valued Contributor


Joined: 11 Jun 2001
Posts: 625
Location: Northern Ireland

PostPosted: Wed Feb 19, 2003 10:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Feb 19, 2003 10:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Feb 19, 2003 10:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Feb 20, 2003 5:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Thu Feb 20, 2003 5:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Feb 20, 2003 5:38 pm    Post subject: Reply with quote

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. Smile

_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Thu Feb 20, 2003 5:45 pm    Post subject: Reply with quote

OK, thanks for the tip.
I'll do some experimenting with this.

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Thu Feb 20, 2003 6:13 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Thu Feb 20, 2003 6:31 pm    Post subject: Reply with quote

OK, thanks Smile
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Tue Feb 25, 2003 11:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Feb 27, 2003 10:33 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group