Hi,
two semantically identical code blocks produce different c++ code in b4a and lead to different behaviour. And the diffent behaviour is the problem. I want to use the code like block 1, but this doesn't work as expected.
I hope, everyone agrees, that block 1 and block 2 should have exactly the same meaning:
Block 1:
Block 2:
SetAtPos is a library function that stores the object reference. Later GetAtPos returns the reference at the given position.
Ending Code:
But the identically ending block gives 2 different log outputs, depending on using block 1 or block 2.
Output Using Block 1:
Output Using Block 2:
That bug is a big problem for my current development, because I can't use my new library reliably. I expect the output from block 2 when using block 1 instead, too.
I appended the full test-project (project and library). The library is a cutout of my current development, only to show the problem.
two semantically identical code blocks produce different c++ code in b4a and lead to different behaviour. And the diffent behaviour is the problem. I want to use the code like block 1, but this doesn't work as expected.
I hope, everyone agrees, that block 1 and block 2 should have exactly the same meaning:
Block 1:
B4X:
For i = 0 To 3
Store1.SetAtPos(i, Element(i))
Next
Block 2:
B4X:
For i = 0 To 3
Select i
Case 0
Store1.SetAtPos(i, Element(i))
Case 1
Store1.SetAtPos(i, Element(i))
Case 2
Store1.SetAtPos(i, Element(i))
Case 3
Store1.SetAtPos(i, Element(i))
End Select
Next
SetAtPos is a library function that stores the object reference. Later GetAtPos returns the reference at the given position.
Ending Code:
B4X:
TempElement = Store1.GetAtPos(0)
Log("Tag: ", TempElement.Tag)
Log(".")
TempElement = Store1.GetAtPos(1)
Log("Tag: ", TempElement.Tag)
Log(".")
TempElement = Store1.GetAtPos(2)
Log("Tag: ", TempElement.Tag)
Log(".")
TempElement = Store1.GetAtPos(3)
Log("Tag: ", TempElement.Tag)
Log(".")
But the identically ending block gives 2 different log outputs, depending on using block 1 or block 2.
Output Using Block 1:
B4X:
AppStart
Tag: 3
.
Tag: 3
.
Tag: 3
.
Tag: 3
.
B4X:
AppStart
Tag: 0
.
Tag: 1
.
Tag: 2
.
Tag: 3
.
That bug is a big problem for my current development, because I can't use my new library reliably. I expect the output from block 2 when using block 1 instead, too.
I appended the full test-project (project and library). The library is a cutout of my current development, only to show the problem.