I'll expand a bit more.

The keys and values of a dictionary are variants. In this case, I am putting strings in there.

Suppose you have three properties in a config file: maxspeed, weight and acceleration, colon and return delimited.

// read the file and store it into a dictionary
Dim fconfigFile As Folderitem = wherever your config file is
Dim dTmp As New Dictionary
Dim sTmp As String
Dim tis As TextInputStream

tis = fconfigFile.OpenAsTextFile

While Not tis.EOF

  sTmp = tis.ReadLine

  dTmp.Value(NthField(sTmp, ":", 1)) = NthField(sTmp, ":", 2)

Wend

// copy data to local variables

car.maxspeed = dTmp.Lookup("maxspeed", <default>)
car.weight = dTmp.Lookup("weight", <default>)
car. acceleration = dTmp.Lookup("acceleration", <default>)

// done.

This is the full code - it *should* work, although I have not tested it; I just typed it in the email. Notice there is no code for every possible value. If one of the values needed in a local variable doesn't exist in your config file, then that entry won't appear in the dictionary, and the Lookup method of the dictionary will instead return whatever default you have set.

HTH
Andrew Keller

On Oct 3, 2006, at 4:19 PM, Kevin Windham wrote:
I don't see how this will save me much work. I still have to create code for every possible value it seems. I mean I already have objects with named properties, there has to be some smart way to take something like car.maxspeed = 248 from a config file and get it into a car object with a maxspeed property. This would be simple in javascript.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to