To save a list, should I use the Registry or a File?

My program utilizes a list stored in an array.  I would like the user to be able to modify the list, and have the changes available the next time the user runs the program.  This program already utilize Registry values for a number of variables.  Should an array of values be saved in the Regisrty?  If so, how?  Bare-in-mind, the number of elements in the array can vary according to what the user enters.  Alternately, should I just write/read the values to/from a file?  Is so, in which directory should I place it?

I am using VB 6.0
tlaksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
I personally prefer putting larger information in INI files and this INI files is ofcourse put in the application path, I only store the path to where the program is in the registry (that way I give fast access to the settings without havin' to clutter the registry).

Is the array really big? Is it string values or numeric values? One way would be to combine all the strings into one big string delimited with a character (i.e. "|", Tab or whatever character that aint being used in the strings). Then when the program wants to read the values back it reads the whole string and just splits the string..
0
mcriderCommented:
Well, you could store your array in the registry by having a key for each item and incrementing the key by one each time you store an item in the array.

For example:

Dim X As Variant
Dim Element As Variant
Dim I As Long

X = Array("AAA", "BBB", "CCC")
For Each Element In X

'TO SAVE OFF SETTINGS    SaveSetting "MyApp", "ArrayList", "Item" + Format(I, "00000"), Element
    I = I + 1
Next

'TO GET BACK SETTINGS
X = GetAllSettings("MyApp", "ArrayList")
For I = LBound(X, 1) To UBound(X, 1)
    Debug.Print X(I, 0), X(I, 1)
Next I


Cheers!
0
moterkCommented:
I agree with VBmaster!

The registry is big enough without storing array data in it.  It should only be used for minimal essential data.  Store it in a file and put the file name (with path) in the registry.  Since the file name is in the registry you can put the file anywhere you want to.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

tlaksAuthor Commented:
I anticipate that my array will not be very large, so mcrider's answer appears appealing, however, one requirement I took for granted is to retain the functionality of the default option of GetSetting which is not available in GetAllSettings.

As for VBmaster's comment, (using an INI file) is there a dynamic way for me to determine where my program is running?  Most of my VB apps are used by myself, and I am poorly versed in the process of "Package and Deployment."  Also, I thought that the Registry made INI files passe.  Could you point me to a good reference on how to write to or format INI files.
0
mcriderCommented:
Well if you want to retain default functionality, you can do it this way:

'TO GET BACK SETTINGS
X = GetAllSettings("MyApp", "ArrayList")
For I = LBound(X, 1) To UBound(X, 1)
    Debug.Print GetSetting("MyApp", "ArrayList", X(I, 0), "DEFAULT")
Next I


Cheers!
0
tlaksAuthor Commented:
My default is an array.  This requires a different value for each array value AND, the number of elements in my original array could vary from what the user enters.  More comments?
0
mcriderCommented:
Keep a counter when going through the FOR LOOP to get the Default value:


'TO GET BACK SETTINGS
X = GetAllSettings("MyApp", "ArrayList")
J=0
For I = LBound(X, 1) To UBound(X, 1)
    Debug.Print GetSetting("MyApp", "ArrayList", X(I, 0), DefArray(j))
    J=J+1
Next I

Cheers!


0
VbmasterCommented:
You can at any time during run-time check the value of App.Path to see where your exe-file is.
0
tlaksAuthor Commented:
I would like to accept VBmaster's comment of Monday, November 15 1999 - 11:06AM EST as my answer.  I used his second option - I "join" my array into a single string, with a carriage return line feed as the delimiter, and save that to the registry.  This also gives me an easy way to allow my user to modify the array.  After GetSetting, I send the array to a textbox (multiline=true).  For the textbox_change event, I split the textbox.text with carriage/return line feed as the delimiter, and assign it to the array.
0
VbmasterCommented:
If this is the case I think you will need to reject the answer, then ask me to "answer the question" or just accept the comment as a answer (might be that this option is not available when you have a proposed answer?).
0
tlaksAuthor Commented:
I would like to accept VBmaster's comment of Monday, November 15 1999 - 11:06AM EST as my answer.  I used his second option - I "join" my array into a single string, with a carriage return line feed as the delimiter, and save that to the registry.  This also gives me an easy way to allow my user to modify the array.  After GetSetting, I send the array to a textbox (multiline=true).  For the textbox_change event, I split the textbox.text with carriage/return line feed as the delimiter, and assign it to the array.
0
VbmasterCommented:
And here comes a 'answer'..
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tlaksAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.