B4J Question Getting a value returns a Null

MathiasM

Active Member
Licensed User
Hello

I'm tearing my hair out over here, a Map object contains a bunch of strings, I try to get a value by a key. But the value is always null.
I have screenshots of my debug process:

The Map, containing the string "B1A"
uJCDKVP.png


The value I'm passing to the Get on that Map is B1A

rbpYWVf.png


The result is Null

rRnd7nA.png



To be complete, this is the code:

PElqNzJ.png


Anyone has a idea what I'm doing wrong? Thanks for any help.
 

OliverA

Expert
Licensed User
Longtime User
Maybe there are one or may spaces at the end of the key value (or non-printable characters).
 
Upvote 0

emexes

Expert
Licensed User
Get the map keys using .GetKeyAt, and have a very close look at the length and character numbers/codes of the "B1A" entry.

Also, B1A is a valid hex number, and unexpected interpretation/casting of numbers has sometimes tripped me up. :rolleyes:
 
Upvote 0

MathiasM

Active Member
Licensed User
Thanks for the help people. I found the issue.
As seen in my second image, the value is "B1A", not B1A. So including the " " signs.

Very stupid of me, I assumed the "" sign was the IDE's way of showing it was a string value. Thanks for guidance!

What is the output of?
B4X:
For Each Key As String In Map.Keys
  Log(Key & ", " & Key.Length)
Next

It showed 5 instead of 3. Which was the point I understand the problem (way too long after hitting the problem). Thanks!
 
Upvote 0
Top