INI file in pb

Just starting out? Need help? Post your questions and find answers here.
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: INI file in pb

Post by Comtois »

have a look at preferencelib.
Please correct my english
http://purebasic.developpez.com/
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: INI file in pb

Post by em_uk »

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Preference example file
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;

If CreatePreferences("Preferences.prefs")
  PreferenceGroup("Global")
    WritePreferenceString("ApplicationName", "MP3 Player")
    WritePreferenceString("Version", "1.1b")

  PreferenceComment(" This is the Window dimension")
  PreferenceComment("")

  PreferenceGroup("Window")
    WritePreferenceLong ("WindowX", 123)
    WritePreferenceLong ("WindowY", 124)
    WritePreferenceFloat("WindowZ", -125.5)

  ClosePreferences()
EndIf


OpenPreferences("Preferences.prefs")

  PreferenceGroup("Window")
    Debug ReadPreferenceLong ("WindowX", 0)
    Debug ReadPreferenceLong ("WindowY", 0)
    Debug ReadPreferenceFloat("WindowZ", 0)
    
  PreferenceGroup("Global")
    Debug ReadPreferenceString("ApplicationName", "")
    Debug ReadPreferenceString("Version", "")
    
ClosePreferences()
----

R Tape loading error, 0:1
nigel
User
User
Posts: 62
Joined: Tue Feb 23, 2010 8:39 pm
Location: Canada

Re: INI file in pb

Post by nigel »

em_uk

I was just taking a look at what I needed to do to create and use an "ini" file and stumbled across your response here to
another user question covering this very topic. Anyway, to cut a long story short, your posted code snippet just saved
me at least two or three hours which I would otherwise have wasted in figuring it out for myself.

Thanks a lot em_uk
Post Reply