aeric Expert Licensed User Longtime User Sep 4, 2020 #1 In Default B4A, I used to declare my global variables in Main and then later I used Starter to declare global variables such as UserID, SQL and KeyValueStore variables. How about B4XPages? Do we store these variable in B4XMainPage?
In Default B4A, I used to declare my global variables in Main and then later I used Starter to declare global variables such as UserID, SQL and KeyValueStore variables. How about B4XPages? Do we store these variable in B4XMainPage?
hatzisn Expert Licensed User Longtime User Sep 4, 2020 #2 B4XPage is a class so if it is necessary to access the variable make it Public and then access it like f.e. Page1.VariableName. If you want to obfuscate it though (f.e. a string) then you should use the Process_Globals of Main or Starter because the strings in a Class are not obfuscated. Upvote 0
B4XPage is a class so if it is necessary to access the variable make it Public and then access it like f.e. Page1.VariableName. If you want to obfuscate it though (f.e. a string) then you should use the Process_Globals of Main or Starter because the strings in a Class are not obfuscated.
aeric Expert Licensed User Longtime User Sep 4, 2020 #3 Yes, I would like to know any "best" practice so when we develop for B4i and B4J will follow the same convention. So I think the correct way is to put those variables in Main class. Upvote 0
Yes, I would like to know any "best" practice so when we develop for B4i and B4J will follow the same convention. So I think the correct way is to put those variables in Main class.
Erel B4X founder Staff member Licensed User Longtime User Sep 6, 2020 #4 aeric said: So I think the correct way is to put those variables in Main class. Click to expand... This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform. Upvote 0
aeric said: So I think the correct way is to put those variables in Main class. Click to expand... This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform.
aeric Expert Licensed User Longtime User Sep 6, 2020 #5 Erel said: This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform. Click to expand... Thanks @Erel for clarification. Upvote 0
Erel said: This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform. Click to expand... Thanks @Erel for clarification.
Alessandro71 Well-Known Member Licensed User Longtime User Sep 6, 2020 #6 Erel said: This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform. Click to expand... And for the obfuscation purpose? I'm currently using a code module with only the strings requiring obfuscation, declared as public and using them from the other pages Upvote 0
Erel said: This is the wrong solution. Put it in B4XMainPage. This way it will be cross platform. Click to expand... And for the obfuscation purpose? I'm currently using a code module with only the strings requiring obfuscation, declared as public and using them from the other pages
Erel B4X founder Staff member Licensed User Longtime User Sep 7, 2020 #7 Alessandro71 said: I'm currently using a code module with only the strings requiring obfuscation, declared as public and using them from the other pages Click to expand... Good solution. Upvote 0
Alessandro71 said: I'm currently using a code module with only the strings requiring obfuscation, declared as public and using them from the other pages Click to expand... Good solution.
gregchao Active Member Licensed User Longtime User Jan 5, 2021 #8 BTW. Just in case it is not obvious to everyone. In B4XMainPage, declare variable as public B4X: Copy Public variablename as string Now you can access it on another page with the code: B4X: Copy B4XPages.MainPage.variablename Upvote 0
BTW. Just in case it is not obvious to everyone. In B4XMainPage, declare variable as public B4X: Copy Public variablename as string Now you can access it on another page with the code: B4X: Copy B4XPages.MainPage.variablename