Bug? Couple of minor differences between B4A and B4i.

MrKim

Well-Known Member
Licensed User
Longtime User
1. In B4A Mod function works with a float. In B4i it does not compile.
B4X:
Dim X As Float
If X Mod 2 = 0 Then  '<Fails in B4i, runs fine inB4a
.
.
.
2. I have a CustomListView that I am using strictly to format for printing to a pdf file. It is never visible. I have two columns of data. I fill it with a column of data then

B4X:
    Do While RS.NextRow
           .
           .
           '
           'Dim bmp As B4XBitmap = PrintCLV.sv.ScrollViewInnerPanel.Snapshot  '[B]This way FAILS in B4i, works in B4a[/B]
            bmp = PrintCLV.sv.ScrollViewInnerPanel.Snapshot
            If Y Mod 2 = 0 Then
                DestRect.Initialize(40, ColTop, 305, (LineHeight * PrintCLV.Size) + ColTop - 10)  '(612W, 792H) 297
            Else
                DestRect.Initialize(305, ColTop, 572, (LineHeight * PrintCLV.Size) + ColTop - 10)  '(612W, 792H) 297
            End If
            RowsLeft = TotalRows - X
            '10/25/12 ColHight = Min(ColHight, (LineHeight * RowsLeft))
            #If B4A
                pdf.Canvas.DrawBitmap(bmp, Null, DestRect)
                pdf.Canvas.DrawText($"(${NumberFormat((Floor(Y / 2) + 1), 1, 0)})"$, (612 / 2), DestRect.Bottom + 30, Typeface.DEFAULT_BOLD, 5, xui.Color_Black, "CENTER")
                pdf.Canvas.DrawLine(DestRect.Left, DestRect.Bottom, DestRect.Right - 1, DestRect.Bottom - 1, xui.Color_Black, .5)
            #ELSE IF B4I
                PDFCanvas.DrawBitmap(bmp, DestRect)
                PDFCanvas.DrawText($"(${(Floor(Y / 2) + 1)})"$, (612 / 2), DestRect.Bottom + 30, Font.CreateNewBold(20), xui.Color_Black, "CENTER")
                PDFCanvas.DrawLine(DestRect.Left, DestRect.Bottom, DestRect.Right - 1, DestRect.Bottom - 1, xui.Color_Black, 1)
                PDFCanvas.Refresh
            #END IF
This works fine in B4A but for some reason in B4i I had to move Dim bmp As B4XBitmap and do a dummy Snapshot before I start looping through data to fill the data.
B4X:
    Dim bmp As B4XBitmap = PrintCLV.sv.ScrollViewInnerPanel.Snapshot  '[B]This seems to be required to fix a bug in B4i[/B]
    Do While RS.NextRow
       .
       .
Otherwise the first column of data looks like This:
1603617054112.png

Instead of this:
1603617222047.png

Note that only the first Column is wrong, and it only happens ONCE. The first time you open the program, go to the print page and create the file. (It is a B4x pages app and this is on its own page.)
 

MrKim

Well-Known Member
Licensed User
Longtime User
1. This is not a bug. It is a known difference in the behavior. You can use Bit.FMod in B4i for mod with float values.
Got it.
2. I cannot say anything about the second one without a small project that demonstrates this issue.
Here is a project. Note the behavior only happens the first time you open the program. After that it works fine.
If I unrem this line 'Dim bmp As B4XBitmap = PrintCLV.sv.ScrollViewInnerPanel.Snapshot 'This seems to be required to fix a bug in B4i
it works fine the first time.
 

Attachments

  • Test.test.zip
    172.9 KB · Views: 203

MrKim

Well-Known Member
Licensed User
Longtime User
1. Try to make the code simpler.
2. Show the list on the screen and see whether it also shows the large column.
Here it is, stripped to its essence - only one column. The first time the file is created it is wrong. The second time it works. The CLV is visible and appears to be the same both times. If you unrem the line noted it works OK the first time.
Please note Erel, I am fine with the workaround, but it took me a while to figure out. I just thought it might be something you would want to know about/fix.
Unless of course I am doing something wrong here, which is always a possibility.:p
 

Attachments

  • Test.test2.zip
    171.7 KB · Views: 172
Top