Better handling of Preference-Files (INI)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Better handling of Preference-Files (INI)

Post by AND51 »

Hello!

Normal file operations are controlled by using IDs. Why don't do the same with Preference-Files (INI-Files).

For example, this code doesn't work:

Code: Select all

CreatePreferences("1.ini")
	WritePreferenceString("111", "111")
	
	CreatePreferences("2.ini")
		WritePreferenceString("222", "2222")
	ClosePreferences()
	
	WritePreferenceString("333", "3333") ; This key/val-pair is not written into the first ini-file
ClosePreferences()
In my opinion, it's better to use IDs, because there are many reasons. For example, I must work with 2 INIs in my current projects now: my own and an external INI-file from another program.
Well, the Workaorund to temporaryly open and close the unneeded INI files is bad.

What do you think about my idea? :)
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

I "requested" this feature some month ago as Pb4.0 was released.

I wonder if it could be threadsave if no ID is given. Check out Freds answer here:

http://www.purebasic.fr/english/viewtop ... highlight=

Anyway, I would request this feature too again. Its not really really necessary but nice to have. #PB_Any should also be supported then. :D

Mike
Tranquil
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Oh, da ist er wieder, mein freund der Tranquil... :D
In the other thread, which Tranquil posted, Fred wrote:You can open one per thread (if you compile in threadmode).
Well, I don't know how to use this "workaround"...?

I want to access different INIs at the same time in the same procedure or main program.

Please, Fred or anbody else of the PB team, can you replay to this thread? What do you think about this request? Is it possible to realize this in one of the next versions of PB?

As I and Tranquil said, we recommend the same handling-method as you use with normal files.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Please, can someone of the PB-Team write an answer?
One INI per Thread is not that good. I would prefer a kind of ID handling like the file-lib. There you also assign different IDs to different opened files.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply