Problem with dictionary

I’m using a dictionary a couple of times in my projects and never had a problem.
Now there is something strange.If I save a dictionary value to a variable and use in an IF statement, or select statement, it never runs through the IF or select case “ABC” part.
using version 2020r2

var sValue as string

sValue = dictionary.value(key)

if sValue = “ABC” then
… // it never gets processed

end if
------------ OR
select case sValue
case “ABC”
… // it never gets processed
case else

end select

it does not process the IF part or the case “ABC” , even in debugger, I can see sValue is set to “ABC”

BUT if I’m saying
sValue = “ABC” then it works fine

can anybody explain that ?

Look at the binary value in the debugger. Something isn’t what you think it is.

Kem, you are right

the dictionary returns “.ASC”
why does it have a dot in front ?

found it, was hard to spot
I’m loading the value as " ABC" ( with a space in front )
it’s my fault

thanks Kem

1 Like

Glad you found it.
In reverse, when trying to move a project between Xojo versions, I found that if the dictionary was populated with a ‘string’ keys of value ‘ABC’
but you later try.

if mydictionary.haskey (somevariable)

where somevariable is of type Text and has a value of “ABC”

then the key is not seen to be the same.
I thought dictionary keys were variants, and I would have expected this to work seamlessly.