Hi,
I have the working code below, but at the moment there are only 4 options.
Eventually there may be hundreds of options, which will mean that using If Statements or Select Case will become impractical due to the ridiculously large volume of code needed.
Is there a better way to do this, which will involve much less code when there are hundreds of options?
Dictionaries are based on a hash so the lookup time is relatively unaffected by the number of items. Although Eli’s alternate suggestion of an in-memory SQLite database would work too, a Dictionary would be far less work, and would probably be faster (just speculating), although either would be, for all intents and purposes, instant.
I’d load the key-value pairs from a text file and stuff them in the dictionary. Then you can easily add/modify them in the text file rather than having tons of Xojo dictionary code.
[code]dim f as folderitem = getOpenFolderitem() // or however you want to locate the file
dim t as new TextinputStream(f)
// lets pretend its a simple tab delimited file
while t.eof <> true
dim s as string = t.readline
dim key as string = s.nthfield(chrb(9), 1)
dim value as string = s.nthfield(chrb(9), 2)
dict.value(key) = value
wend
[/code]