Bug? B4XFont declared without value assigned to it doesn't show a compiler error

walt61

Active Member
Licensed User
Longtime User
See the comments in the code. The compiler warning disappears; I found this out with a B4XPages project that was first developed in B4J (with an Arial font, assigned in a conditional "#If B4J" block). B4A didn't complain about the font variable (which was declared unconditionally) not having been assigned a value, but any views that were assigned that font didn't show any text. I thought there were Gremlins in my code.

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI

    Private Button1 As B4XView
    Private fontArial_13 As B4XFont ' <---- Declare the variable but never assign a value to it
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    ' With the next line commented out, there is a compiler warning:
    '      B4XMainPage - 13: Variable 'fontArial_13' is never assigned any value. (warning #10)
    ' When the line is 'active', the compiler warning disappears, and there is no
    ' run time error either; when running the app, the button's text disappears:
    Button1.Font = fontArial_13
End Sub
 

Attachments

  • FontIssue.zip
    9.9 KB · Views: 129
Top