SMOOTSARA Active Member Licensed User Longtime User Apr 17, 2021 #1 Hi Is it correct to use "if" in the Process_Globals section? For example the following code B4X: Copy 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
Hi Is it correct to use "if" in the Process_Globals section? For example the following code B4X: Copy 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 Apr 17, 2021 #3 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
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.
LucaMs Expert Licensed User Longtime User Apr 17, 2021 #4 agraham said: 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. Click to expand... 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
agraham said: 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. Click to expand... 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.
Erel B4X founder Staff member Licensed User Longtime User Apr 18, 2021 #5 It is not correct. The global subs should only be used for variables declarations and simple assignments. This code might break in the future. Tip: the less you use code modules the better. Upvote 0
It is not correct. The global subs should only be used for variables declarations and simple assignments. This code might break in the future. Tip: the less you use code modules the better.