Page 1 of 1

What's the best way for a ini file ?

Posted: Sat Aug 30, 2008 11:09 pm
by jmauver
Hi guys,

I have all the settings for my application stored on constants. It is ok if you do not plan to change the settings like folder locations, database name etc.
But I think I need to give more flexibility in case someone else uses my application in another computer. So, as I can not read settings from a file and assign to it to an constant, is there a standard or best practice to load settings to your PB application like an ini file ? In fact it would be great to read data from a file and assign to a constant as I feel more secure that way. Any suggestion or experience in this issue will be welcome.

Thanks all.

Posted: Sat Aug 30, 2008 11:20 pm
by netmaestro
How about the preferences library?

Posted: Sat Aug 30, 2008 11:31 pm
by jmauver
netmaestro wrote:How about the preferences library?
Hi netmaestro,

You mean I create a preferences library ? Or there is a library for this purpose ? I searched the forum and could not find it. If there is a library, could you tell the link ?

Thanks a million.

Posted: Sat Aug 30, 2008 11:33 pm
by Heathen
jmauver wrote:
netmaestro wrote:How about the preferences library?
Hi netmaestro,

You mean I create a preferences library ? Or there is a library for this purpose ? I searched the forum and could not find it. If there is a library, could you tell the link ?

Thanks a million.
I think he's referring to the preferences library that's built into PB.

Posted: Sat Aug 30, 2008 11:33 pm
by ts-soft
You can found the preference lib in the HelpFile from PB :wink:

Posted: Sat Aug 30, 2008 11:51 pm
by Kaeru Gaman

Ops!

Posted: Sun Aug 31, 2008 12:02 am
by jmauver
Gosh, what a shame I did not know PB already have it :oops: Sorry guys.

The library handles read/write groups and values. I presume that I have to read and store the settings on globals.

Thank you all.

Posted: Sun Aug 31, 2008 12:12 am
by Kaeru Gaman
net necessarily Globals.
you can also use Shared
or read the INI in a Proc where you directly work with the values.

Posted: Sun Aug 31, 2008 12:25 am
by Baldrick
@jmauver,
Have a quick look in your PB Examples\Sources\Screen3drequester.pb. It contains a nice simple working example of using preferences.

Thanks!

Posted: Sun Aug 31, 2008 12:51 am
by jmauver
Many thanks for the comments and links. :D

Posted: Sun Aug 31, 2008 3:06 am
by Mistrel
The only downside I found with the preferences library is that you can't easily rename a group.

http://www.purebasic.fr/english/viewtopic.php?t=32119