Add InsertPreferences/ExtractPreferences

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Add InsertPreferences/ExtractPreferences

Post by Quin »

As an application gets more and more complicated, storing all user configuration data in a structure seems like a good idea. However, if we're using the preferences library, there's no easy way to load this data like there is with JSON/XML/etc. Is it possible to add functions that can load/save preference files using structures?
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Add InsertPreferences/ExtractPreferences

Post by Marc56us »

Hi,

I don't know, but personally, I don't like structured flat data files, so I'd avoid using pref files in any way other than the one intended.
Similarly, Json and XML have both advantages and disadvantages
Advantage: Single-pass backup readout
Disadvantage: a single character error can render the file unreadable
In addition, both are very difficult to edit manually.

If the pref file becomes too large, the best solution is an SQLite database. (IMHO)
This is what some browsers (i.e. Firefox) do for bookmark.
nsstudios
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: Add InsertPreferences/ExtractPreferences

Post by nsstudios »

+1
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Add InsertPreferences/ExtractPreferences

Post by Quin »

Marc56us wrote: Tue Mar 25, 2025 9:33 pm I don't know, but personally, I don't like structured flat data files, so I'd avoid using pref files in any way other than the one intended.
Structured flat data files? Who's to say it would have to be structured and flat? If I did:

Code: Select all

Structure Prefs
    General.GeneralPrefs
EndStructure

Structure GeneralPrefs
    Name.s
EndStructure
This would create a general section in the ini file with name, in my mind.
Post Reply