Copy elements from a map to another

stefanoa

Active Member
Licensed User
Longtime User
how can I create a copy of elements from a map to another?

ex. i have a map with 100 elements (with 2 informations, title and ID)

I will filter this map and i want to create a second map with only the 20 elements filtered (with title & ID)

how can i copy the value filtered from a map to the other??

i can retrieve value from the original map with:

B4X:
searchTitle=m.Get("Title" & i)
IDX=m.Get("ID" & i)

and then?

thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are two option:
1. Go over all the items and copy the ones you want:
B4X:
For i = 0 To m1.Size - 1
 Dim key, value as string
 key = m1.GetKeyAt(i)
 value = m1.GetValueAt(i)
 If value = ... Then
   m2.Put(key, value)
 End If
2. If you want to copy a specific item then you can write:
B4X:
m2.Put(searchTitle, IDX)
 
Upvote 0
Top