Hi

I am toying with OO approaches to handling INI files. First of all I am a great believer in NOT reinventing wheels so if something along the lines I am describing already exists, please let me know. The general idea is this

At the beginning of the app, create a "settings object" and populate it with settings from an INI file

While the app is running, get and set settings using the "settings object" and its objects and properties. Maybe even delete and add new ones too ! No access to the INI file at this stage.

At the end of the app, write all the settings back to the INI file.

Getting and setting vales (from/to the INI file) will be done only once (at the beginning and end of the application) and will be done using the registry class that comes with VFP.

Like an INI file, I want whatever approach I use to emulate the "sections" approach of INI files. Moreover this approach would enable access throughout the running app to more than one set of settings (oUserSettings and oGeneralSettings could co-exist for example).

I have thought of two ways of doing this and would like coments/ideas/suggestions - this is the barest outline of the approach.

Method 1

oSettings (based on the custom class) contains oSection objects (also based on the custom class). There is one oSection object for each section in the INI file and each has the same name as the corresponding section in the INI file. Restrictions will apply where the section names contain characters (esp spaces) that would make invalid object names.

Each oSection object has custom properties, each one corresponding to an entry in the INI file.

I have already done some work on this approach and it seems doable.

Method 2

Based on collections. oSettings is a collection of oSections collections and the oSections are collections of values (this approach would use character keys for all the items in the oSettings collection and for all of the items in each of the oSections collections.

There is another refinement that I am thinking about and that is the use of "enhanced" INI files (these would not be compatible with normal INI files). Optionally an entry in an enhanced INI file would look like this:

[Section1]
Setting1=10 [N]
Setting2=Y [L]
Setting3=503233 [C]

I would appreciate any feedback or suggestions as I would like to try to progress this idea

Cheers








_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to