managing user preferences...opinions needed 
Author Message
 managing user preferences...opinions needed

I have an app with many user-defined preferences such as colors, search
paths, and misc values. I also have internal variables such as saved screen
positions and so forth. I am temporarily using a global UDT and
loading/saving these values to a binary file during development. For example
(short list):

******

Type AppPrefs
    .SelectedInDeviceID = 1
    .SelectedOutDeviceID = 2
    .Timeout = 1000
    .SysDirectory = App.Path & "\sysex"
    .FilterDirectory = App.Path & "\filters"
    ---
    ---
    ---
    ' color values
    .Color_1 = &HFF00&
    .Color_2 = vbBlack
    ---
    ---
End Type

Public Preferences as AppPrefs

******

Now that I'm just about "finished", I'm ready to set up reg keys and a
preferences page for my app, and read/store these values in the registry.
Reading/writing to the registry is no problem, but....

Is there a better way of storing these values during program execution, so
that I can just loop thru them when reading/writing to the registry? A
simple array would be easy enough, but it would make keeping track of them
in the source code a nightmare. [MyControl.Backcolor = Preferences(?)]

The UDT makes it easy to identify them in the source, but then I end up with
WAY to many lines of code (I'm using a registry OCX) :

******

    With Reg1
        .hKey = HKEY_CURRENT_USER
        .Path = "SOFTWARE\MyApp"
        .ValueName = "SelectedInDeviceID"
        Preferences.SelectedInDeviceID= .GetValue

        ---
        ---
        ---
        ---
    End With

******

How about a collection of some sort? Something that would offer the
advantage of refering to each preference by name in code, but allowing a
loop for storing and retrieving?

Any ideas?

Thanks,

Calan



Mon, 02 May 2005 11:06:33 GMT  
 managing user preferences...opinions needed


Quote:
>Public Preferences as AppPrefs

>Now that I'm just about "finished", I'm ready to set up reg keys and a
>preferences page for my app, and read/store these values in the registry.
>Reading/writing to the registry is no problem, but....

>Is there a better way of storing these values during program execution, so

YES !
Use an Ini file. Actually since i know that you have the binary format
down to a T now <g>, use a binary config file in App.Path.
That way you just go
Put  cfgFile, , Prefrences  to save and
Get cfgFile,, Preferneces to load the settings.

There are a few good things about using binary configs.
1. Security.
If the user wants to play with the config file, it will be unreadable
as it will show garbage in a text editor.
2.  Speed.
Put and Get is lightning on a UDT.
3. Convenience.
All you have to do is have a dirty flag added to the UDT which you set
when an option is changed. then on exit or periodic checks you can
simply check that flag, toggle back to False and write it to the file.
4. Multiple user prefs.
It's quite easy to create and switch between "named" configurations.

Drawbacks
1. If the user indeed plays with the config file it is likely that
they will stuff it up. So you do need to have some way of checking the
validity of the config file and if it fails the check reset to
defaults.
In my opinion the pros defeat the con, especially in view that a) they
shouldn't play with the damn thing and b) a default config is
necessary no matter how you store the prefs.

--
Regards, Frank



Mon, 02 May 2005 11:35:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. User Preferences located in a seperate file

2. Use of app.config and saving user preferences...

3. Advice on saving array of users preferences

4. User Preferences

5. Saving user preferences

6. Default User Preferences

7. Using VBA in Access to manage user accounts and directories

8. New Product: Manage Access Users and Groups

9. newbie - managing data from user form

10. website for managing users

11. programmatically managing users in NT

12. Managing User State in Multiple Servers

 

 
Powered by phpBB® Forum Software