If keywords(index).HasKey(word) Then
k=keywords(index).value(word)
words.append word:k
If word="INTEGER" Then debug "HasKey "+word+":"+Str(k)
Else
words.append word:0
For Each key As String In keywords(index).Keys
If key=word Then debug "KY:"+key+"="+keywords(index).value(key)
Next
End If
this code is supposed to lookup “WORD” in the KEYWORDS dictionary and return a value of K
if the word is not in the dictionary is defaults to 0 [ie. after the ELSE]
HOWEVER… if is NEVER doing the before ELSE code, yet if the FOR EACH loop it is showing me the word I’m looking for!
This was working the other day… not sure what could have happened…
AND yes… there are NO whitespace characters …
replaceing the above code with
k=0
For Each key As String In keywords(index).Keys
If key=word Then
k=keywords(index).value(key)
exit for
end if
Next
words.append word:k
DOES work… but defeats the purpose of a dictionary
Scratch that. HasKey is not case sensitive. Don’t remember where I got that notion. But there are some variations where dictionary hash and simple comparison differ.
String keys in a Dictionary are case-insensitive, but encodings will matter. If you try to use the same word with different encodings, I believe the lookup will fail.
BTW, once you get that part figured out, you might want to use Lookup instead.
k = keywords( index ).Lookup( word, 0 )
words.Append word:k