What's the best way for a ini file ?

Just starting out? Need help? Post your questions and find answers here.
jmauver
User
User
Posts: 36
Joined: Thu Jun 19, 2008 1:21 pm
Location: London

What's the best way for a ini file ?

Post 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.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

How about the preferences library?
BERESHEIT
jmauver
User
User
Posts: 36
Joined: Thu Jun 19, 2008 1:21 pm
Location: London

Post 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.
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post 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.
I love Purebasic.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

You can found the preference lib in the HelpFile from PB :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

oh... and have a nice day.
jmauver
User
User
Posts: 36
Joined: Thu Jun 19, 2008 1:21 pm
Location: London

Ops!

Post 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.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
Baldrick
Addict
Addict
Posts: 860
Joined: Fri Jul 02, 2004 6:49 pm
Location: Australia

Post by Baldrick »

@jmauver,
Have a quick look in your PB Examples\Sources\Screen3drequester.pb. It contains a nice simple working example of using preferences.
jmauver
User
User
Posts: 36
Joined: Thu Jun 19, 2008 1:21 pm
Location: London

Thanks!

Post by jmauver »

Many thanks for the comments and links. :D
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post 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
Post Reply