It is currently Tue Sep 29, 2020 10:32 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: reading ini headings
PostPosted: Thu Dec 04, 2003 9:01 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Sep 12, 2003 10:40 pm
Posts: 665
Location: Tallahassee, Florida
ok i have a program for my PHd that stores all its data in an INI file. i have a heading called [experiment], follwed by keys and values that store the state of checkboxes and string gadgets. what i want to be able to do is open up the database file, and have my program read ONLY the HEADINGS of the INI file and then list them in a combobox. then when i click the combobox item, i want it to read the values of that specific heading and set the data. so it looks like this

[experiment 1]
checkbox1=yes
ect....

[experiment 4]
checkbox1=no

[experiment 3]
checkbox1=no

[experiment 3]

[experiment 4]

i want the combobox to list

experiment 1
experiment 2
experiment 3
experiment 4
all the way up to the number of experiment headings

any ideas?

_________________
Code:
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 04, 2003 9:19 pm 
Offline
Enthusiast
Enthusiast

Joined: Fri Apr 25, 2003 11:08 pm
Posts: 460
localmotion,

If your headings are always of the form "Experiment X", then something like this should work:
Code:
OpenPreferences("exp.ini")

Exp.l = 1
Repeat
  Experiment.s = "Experiment " + Str(Exp)
  Result.l = PreferenceGroup(Experiment)
  If Result
    Debug Experiment ; <-- get values under heading here
    Exp + 1
  EndIf
Until Result = 0

ClosePreferences()

Eric


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 04, 2003 9:26 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 987
Location: Canada
Or this...
Code:
If ReadFile(0,"yourfile.ini")
  While Eof(0)=0
    dat.s=ReadString()
    If Left(dat,1)="["
      Debug Mid(dat,2,Len(dat)-2)  ;<-- add to combobox here
    EndIf
  Wend
  CloseFile(0)
EndIf

_________________
Image Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 60 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye