J John Sturt Active Member Licensed User Longtime User Mar 15, 2014 #1 Hello I seem to have missed something because this is driving me nuts. I have two activities and want to pass a string from one to the other. Essentially i have this: Activity One Sub Process+_Globals Dim Myvalue As String end Sub ... Sub Whatever Start Activity2 end Sub Activity 2 When i try to assign or even print to the log all i get is variable undeclareed Any Help?
Hello I seem to have missed something because this is driving me nuts. I have two activities and want to pass a string from one to the other. Essentially i have this: Activity One Sub Process+_Globals Dim Myvalue As String end Sub ... Sub Whatever Start Activity2 end Sub Activity 2 When i try to assign or even print to the log all i get is variable undeclareed Any Help?
klaus Expert Licensed User Longtime User Mar 15, 2014 #2 What's the name of Activity1 ? In Activity2 you must call the variable NameOfActivity1.Myvalue. If Activity1 is Main then you must use Main.Myvariable in Activita2 ! Upvote 0
What's the name of Activity1 ? In Activity2 you must call the variable NameOfActivity1.Myvalue. If Activity1 is Main then you must use Main.Myvariable in Activita2 !
J John Sturt Active Member Licensed User Longtime User Mar 17, 2014 #3 Thank You for your reply but the problem i am having is not a StartActivity it is a passing Variable problem. In Activity1 i write sub process_globals dim MyValue As String end Sub I then go on to call Activity 2 and try to access "MyValue" from within Activity 2 for example Log (MyValue) At the debug rapid stage i get the error Undeclared variable MyValue Any help? Upvote 0
Thank You for your reply but the problem i am having is not a StartActivity it is a passing Variable problem. In Activity1 i write sub process_globals dim MyValue As String end Sub I then go on to call Activity 2 and try to access "MyValue" from within Activity 2 for example Log (MyValue) At the debug rapid stage i get the error Undeclared variable MyValue Any help?
mangojack Expert Licensed User Longtime User Mar 17, 2014 #4 John .. Please use [code ] tags when posting code ... easier to read. (see images) As Klaus stated , you must reference the activity name where you declared the variable. you have 2 Activities.. 'Activity1' and 'Activity2' In Activity1 Code: Sub Process_Globals Dim MyValue As String = "ABC" End Sub Then in Activity2 .. Code: Log (Activity1.MyValue) '...make reference to the activity the variable was dimed. Attachments Code Tags.JPG 13.1 KB · Views: 330 Auto Code Tags.JPG 11.5 KB · Views: 260 Last edited: Mar 17, 2014 Upvote 0
John .. Please use [code ] tags when posting code ... easier to read. (see images) As Klaus stated , you must reference the activity name where you declared the variable. you have 2 Activities.. 'Activity1' and 'Activity2' In Activity1 Code: Sub Process_Globals Dim MyValue As String = "ABC" End Sub Then in Activity2 .. Code: Log (Activity1.MyValue) '...make reference to the activity the variable was dimed.
J John Sturt Active Member Licensed User Longtime User Mar 17, 2014 #5 Thank You both that now makes a lot of sense.. Upvote 0
mangojack Expert Licensed User Longtime User Mar 17, 2014 #6 Your welcome .. May you B4A experience be long and fruitful ... Upvote 0
E ELCHARO Member Licensed User Longtime User Mar 11, 2015 #7 HI! I have a problem. I can access to main.some_variable from a second activity. I can write main.some_variable=0 from a second activity But when return to main, i lose this changes. Why,How, What, can do to mantein this values. Thanks. Upvote 0
HI! I have a problem. I can access to main.some_variable from a second activity. I can write main.some_variable=0 from a second activity But when return to main, i lose this changes. Why,How, What, can do to mantein this values. Thanks.
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2015 #8 Process global variables maintain their value as long as the process is alive. Upvote 0