How do I use Process_Globals?

jkurant

Member
Licensed User
Longtime User
I have an main activity (my app ui) that calls another activity (preferences) and from that activity I call yet another activity (EditMedicationActivity). I need to pass in the medication number.

So, I declared a variable MedicationToBeEdited in Process_Globals:

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim MedicationToBeEdited As Int
End Sub

Well, I can't access this variable in the other activity. I even declared it again in that activity, but I didn't really think that would work.

I have enclosed my app, can someone tell me what I am doing wrong?

To test the app, launch it, then touch the menu key to bring up the preferences activity, then touch the little button with the > next to "1) Button 1".

That will eventually bring up an EditMedication layout, but first I am displaying a msgbox that shows the value of MedicationToBeEdited, which is always 0.

I read this page but it didn't answer my question.

Any help will be most appreciated!
 

Attachments

  • KurantMeds.zip
    16.4 KB · Views: 302

Newman

Member
Licensed User
Longtime User
Try this:

B4X:
Main.MedicationToBeEdited

If the global variable is in another activity use that activity name instead of Main.
 
Last edited:
  • Like
Reactions: MHS
Upvote 0
Top