Have a simple B4A app with 2 modules, Main and Starter. Both need to do logging, but only in debugging mode. I have a Public variable for this bLog, which I have declared in the Starter module like this:
The Sub that does the logging is in the Starter module:
Now I thought that Sub RunLog would be visible to both modules, so there would be no need to add
this Sub to both modules, but I get:
Undeclared variable 'RunLog' is used before it was assigned a value
if that sub is left out of either module.
In the Main module I have to do:
bLog is set at the very first opportunity in the Starter module:
Is there a way to avoid duplication of this Sub?
RBS
B4X:
Sub Process_Globals
Public bLog As Boolean
End Sub
The Sub that does the logging is in the Starter module:
B4X:
Sub RunLog(strLogText As String)
If bLog Then
Log(strLogText)
End If
End Sub
Now I thought that Sub RunLog would be visible to both modules, so there would be no need to add
this Sub to both modules, but I get:
Undeclared variable 'RunLog' is used before it was assigned a value
if that sub is left out of either module.
In the Main module I have to do:
B4X:
Sub RunLog(strLogText As String)
If Starter.bLog Then '<<<< note Starter here
Log(strLogText)
End If
End Sub
bLog is set at the very first opportunity in the Starter module:
B4X:
Sub Service_Create
bLog = r.GetStaticField("anywheresoftware.b4a.BA", "debugMode")
Is there a way to avoid duplication of this Sub?
RBS