B4J Question [BANano] Iteration over Map-Items fails

Kiffi

Well-Known Member
Licensed User
Longtime User
Hello,

when i try to iterate over Map-Items, i get an uncaught ReferenceError ("$ is not defined").

B4J-Code:
B4X:
Dim myMap As Map = CreateMap("January": 1, "February": 2)

Log(myMap.Get("January"))

For i = 0 To myMap.Size - 1
    Log(myMap.GetKeyAt(i))
    Log(myMap.GetValueAt(i))
Next

JS-Code:
B4X:
// [62]  Dim myMap As Map = CreateMap( {24} : 1, {25} : 2)
_mymap={"January":1, "February":2};
// [64]  Log(myMap.Get( {26} ))
console.log(_mymap["January"]);
// [66]  For i = 0 To myMap.Size - 1
for (_i=0;_i<=$.map(_mymap, function(n, i) { return i; }).length-1;_i++) {
// [67]  Log(myMap.GetKeyAt(i))
console.log(banano_getB4JKeyAt(_mymap,_i));
// [68]  Log(myMap.GetValueAt(i))
console.log(banano_getB4JValueAt(_mymap,_i));
// [69]  Next
}

Thanks in advance & Greetings ... Peter
 

alwaysbusy

Expert
Licensed User
Longtime User
for (_i=0;_i<=$.map(_mymap, function(n, i) { return i; }).length-1;_i++) {
This is indeed a bug. I've copied the map code from B4JS (in ABM), but this code appears to still use jQuery ($) (which is not used in BANano). I will have to rewrite this code to vanilla JS.
 
Upvote 0
Top