Page 1 of 1

Re: INI file in pb

Posted: Tue May 03, 2011 4:29 pm
by Comtois
have a look at preferencelib.

Re: INI file in pb

Posted: Sat May 14, 2011 10:12 am
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()

Re: INI file in pb

Posted: Wed Aug 24, 2011 1:49 am
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