Kiffi Well-Known Member Licensed User Longtime User Dec 3, 2018 #1 It's me again (using BANano 1.02) I have a class ListView: Code: Sub Class_Globals Public Items As List End Sub Public Sub Initialize Items.Initialize End Sub Public Sub AddItem(Item As ListViewItem) Items.Add(Item) End Sub I have a class ListViewItem: Code: Sub Class_Globals Public Text As String End Sub Public Sub Initialize Text = "" End Sub and i have this code to add items to the ListView: Code: Dim myListView As ListView myListView.Initialize For Counter = 0 To 9 Dim myListViewItem As ListViewItem myListViewItem.Initialize myListViewItem.Text = "ListViewItem " & Counter myListView.AddItem(myListViewItem) Next now i want to iterate over all items in myListView: Code: For Each myLVI As ListViewItem In myListView.Items Log(myLVI.Text) Next However the transpiled JavaScript doesn't iterate over the items but over the ListView: Code: // [73] For Each myLVI As ListViewItem In myListView.Items for (_mylvi in _mylistview) { // [74] Log(myLVI.Text) console.log(_mylvi._text); // [75] Next } Thanks in advance & Greetings ... Peter
It's me again (using BANano 1.02) I have a class ListView: Code: Sub Class_Globals Public Items As List End Sub Public Sub Initialize Items.Initialize End Sub Public Sub AddItem(Item As ListViewItem) Items.Add(Item) End Sub I have a class ListViewItem: Code: Sub Class_Globals Public Text As String End Sub Public Sub Initialize Text = "" End Sub and i have this code to add items to the ListView: Code: Dim myListView As ListView myListView.Initialize For Counter = 0 To 9 Dim myListViewItem As ListViewItem myListViewItem.Initialize myListViewItem.Text = "ListViewItem " & Counter myListView.AddItem(myListViewItem) Next now i want to iterate over all items in myListView: Code: For Each myLVI As ListViewItem In myListView.Items Log(myLVI.Text) Next However the transpiled JavaScript doesn't iterate over the items but over the ListView: Code: // [73] For Each myLVI As ListViewItem In myListView.Items for (_mylvi in _mylistview) { // [74] Log(myLVI.Text) console.log(_mylvi._text); // [75] Next } Thanks in advance & Greetings ... Peter
alwaysbusy Expert Licensed User Longtime User Dec 3, 2018 #2 I don't think this works yet (a sub variable as the 'IN'). Try this (untested, I'm not at my PC): Code: Dim tmpList as List = myListView.Items For Each myLVI As ListViewItem In tmpList Log(myLVI.Text) Next For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid. B4X wasn't build in a day either The more BANano evolves, the closer I will get it to all B4J can do. This is a prime example of what I will look for in the next version of BANano. Upvote 0
I don't think this works yet (a sub variable as the 'IN'). Try this (untested, I'm not at my PC): Code: Dim tmpList as List = myListView.Items For Each myLVI As ListViewItem In tmpList Log(myLVI.Text) Next For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid. B4X wasn't build in a day either The more BANano evolves, the closer I will get it to all B4J can do. This is a prime example of what I will look for in the next version of BANano.
alwaysbusy Expert Licensed User Longtime User Dec 3, 2018 #3 alwaysbusy said: For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid Click to expand... But don't hesitate to report such cases! They help me a lot to refine the transpiler. Upvote 0
alwaysbusy said: For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid Click to expand... But don't hesitate to report such cases! They help me a lot to refine the transpiler.
Kiffi Well-Known Member Licensed User Longtime User Dec 3, 2018 #4 alwaysbusy said: Try this [...] Click to expand... Then I get an array of ListViewItems. When I iterate over this, myLVI only contains the array indexes. It's too complicated for me. Instead I will iterate classically with a counter until further notice. Code: For Counter = 0 To myListView.Items.Size - 1 Dim myLVI As ListViewItem myLVI = myListView.Items.Get(Counter) Log(myLVI.Text) Next alwaysbusy said: For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid. Click to expand... no problem. Right now it's hard for me to see if I might have done something wrong, or if it's a feature yet to be implemented, or if it's a bug. alwaysbusy said: But don't hesitate to report such cases! Click to expand... ok, i'll be back! Thanks & Greetings ... Peter Upvote 0
alwaysbusy said: Try this [...] Click to expand... Then I get an array of ListViewItems. When I iterate over this, myLVI only contains the array indexes. It's too complicated for me. Instead I will iterate classically with a counter until further notice. Code: For Counter = 0 To myListView.Items.Size - 1 Dim myLVI As ListViewItem myLVI = myListView.Items.Get(Counter) Log(myLVI.Text) Next alwaysbusy said: For now, sometimes you will have to break the code a bit down to simpler objects I'm afraid. Click to expand... no problem. Right now it's hard for me to see if I might have done something wrong, or if it's a feature yet to be implemented, or if it's a bug. alwaysbusy said: But don't hesitate to report such cases! Click to expand... ok, i'll be back! Thanks & Greetings ... Peter
alwaysbusy Expert Licensed User Longtime User Dec 4, 2018 #5 Uploaded version 1.03 which should fix both the original for each and the iteration over a list as proposed in #2 Download: https://www.b4x.com/android/forum/threads/banano-progressive-web-app-library.99740/#post-627764 Upvote 0
Uploaded version 1.03 which should fix both the original for each and the iteration over a list as proposed in #2 Download: https://www.b4x.com/android/forum/threads/banano-progressive-web-app-library.99740/#post-627764
Kiffi Well-Known Member Licensed User Longtime User Dec 4, 2018 #6 Great! Thanks a lot, Alain! (dancing BANano) Upvote 0