Android Question Use if in the Process_Globals in Code Module

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi

Is it correct to use "if" in the Process_Globals section?
For example the following code


B4X:
in Code Module


Sub Process_Globals
    
    If Application.VersionCode =1 Then
        Dim str1 As String = "ver_1"
        Else
        Dim str1 As String = "-----"
    End If
    
End Sub
 

agraham

Expert
Licensed User
Longtime User
While you can get away with it most times it is not recommended to run code in the Process_Globals and Globals Subs.

For good style you should really set a default value in Process_Globals and reset it if necessary in Activity_Create.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
While you can get away with it most times it is not recommended to run code in the Process_Globals and Globals Subs.

For good style you should really set a default value in Process_Globals and reset it if necessary in Activity_Create.
Correct. For "good style", however, you shouldn't even set the variable values there.
I think that is a special case, where a variable is used as if it were a constant (but dependent on...) and so I would say that way can be acceptable... as exception.
 
Upvote 0
Top