Map - Problem with get

stefanoa

Active Member
Licensed User
Longtime User
i have a map "m" filled and then i compile another map "filesMap" with some elements from first map:

B4X:
   For i = 0 To (m.Size / 9) - 1
      filesMap.put( m.Get("ID"), m.Get("Title"))
      ...
        next

with this control it's all ok!:
B4X:
Dim i As Int
Log("filesMap.Size:" & filesMap.Size)
For i = 0 To filesMap.Size - 1
   Log("Key:" & filesMap.GetKeyAt(i) & " - " & "Value:" & filesMap.GetValueAt(i))
Next

and the result is (for example):
Key:33297 - Value:Everybody's Broken
Key:33290 - Value:Lost Highway

but if i do:
B4X:
      Msgbox(filesMap.get(33297), "GetField") 
or
      Msgbox(filesMap.get("33297"), "GetField")

the result is NULL !!!
why??
:sign0085:
 
Last edited:

stefanoa

Active Member
Licensed User
Longtime User
m.size is multiple of 9 but however variable "i" is always int, because start at 0, with step 1 and finish at (m.size /9)

correction: in the 1' code is: filesMap.put( m.Get("ID"), m.Get("Title"))

PS: in LOG it's all ok: in the example: Key:33297 - Value:Everybody's Broken but the "get" return Value=NULL !
 
Last edited:
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
containskey it's always "false" :(

B4X:
For i = 0 To filesMap.Size - 1
   Log("Key:" & filesMap.GetKeyAt(i) & " - " & "Value:" & filesMap.GetValueAt(i))
Next 

Msgbox(filesMap.ContainsKey(33297) , "") 
or
Msgbox(filesMap.ContainsKey("33297") , "")

for next >>> Key:33297 - Value:Everybody's Broken
ContainsKey >>> is always false
 
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
ok..I solved it by putting ID to a string variable:

B4X:
Dim x As String
x=m.Get("ID" & i)
filesMap.put( x,m.Get("Title" & i))
...

and then, to retrieve the value:
B4X:
Dim x As String
x=IDx    '--- IDx it's a INT and contain ID value
Msgbox(filesMap.get(x) , "value")

thanks for support! :)
 
Upvote 0

CharlesIPTI

Active Member
Licensed User
Longtime User
Map get Or GetValueAt

Personally Don't Like Map.Get
its all very convoluted

Attached Project...
Hope it helps someone
 

Attachments

  • Small Map Kraizness.zip
    5.7 KB · Views: 130
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is an OLD thread! Please start a new thread providing much more informations on what you did, what you expected and what you got.

But do this in a new thread
 
Upvote 0
Top