Sharing activity's variables with static module

DOM85

Active Member
Licensed User
Longtime User
Hi,
Sorry for my question that may seem null, but i don't undesterdand how i could use in my static module datas declared in main activity. In my static module i tried to name main data by prefixing them with "main.", but i always obtain complie error. Maybe i am too much focalized on windows mobile data exchange, excuse me for that. But i need your help!!
Thank you!!
 

kickaha

Well-Known Member
Licensed User
Longtime User
Variables have to be declared in Process_Globals for them to be available to other modules.

You are right in using "main." (when accessing Process_Globals from main) to prefix the name.
 
Upvote 0

DOM85

Active Member
Licensed User
Longtime User
Calling static module

Variables have to be declared in Process_Globals for them to be available to other modules.

You are right in using "main." (when accessing Process_Globals from main) to prefix the name.

Thank you For your answer. I did like you show me.
Now i have a compile error on line calling module, please could you help me where i made an error :
Thank you !!!


ToggleBoutons: activity Main

Sub Process_Globals
Dim ToggleBoutonHaut As ToggleButton
Dim ToggleBoutonFin As ToggleButton
Dim Label06 As Label
Dim Fin As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("ToggleBoutons")
Fin=""
Do While Fin=""
24 ModuleToggle.TestBouton
DoEvents
Loop
Activity.Finish
End Sub




ModuleToggle: (static module)

Sub TestBouton
If Main.Toggleboutonhaut.Checked=True Then Main.Label06.TEXT="HAUT"
If Main.Toggleboutonhaut.Checked=False Then Main.Label06.TEXT=" "
If main.ToggleboutonFin.Checked=True Then Main.Fin="O"
End Sub



Compiling code. Error
Error compiling program.
Error description: Unknown member: testbouton
Occurred on line: 24
ModuleToggle.TestBouton
Word: testbouton
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Seems an odd error, as I would have expected compilation to fail as you cannot have ToggleButtons (or any other views) in Process_Globals.

I think you need to post an app that shows the problem.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Did you post the line that raises this error?
It should be: "ModuleToggle.TestBouton" according to the error message.

B4X:
Sub Process_Globals
[COLOR="Blue"]Dim ToggleBoutonHaut As ToggleButton
Dim ToggleBoutonFin As ToggleButton
Dim Label06 As Label[/COLOR]
Dim Fin As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("ToggleBoutons")
Fin=""
Do While Fin=""
[COLOR="Red"]24 ModuleToggle.TestBouton[/COLOR]
DoEvents
Loop
Activity.Finish
End Sub

Erel,

I assume that the line in red is the offender and the OP has added the "24" to show its line number.

I am more baffled by the lines I have hilighted in blue as they should not get through the compiler as I understand things.

The code given seems to be a very nasty way of making the app wait for a ToggleButton to be checked.
 
Upvote 0

DOM85

Active Member
Licensed User
Longtime User
Calling static module

Did you post the line that raises this error?
It should be: "ModuleToggle.TestBouton" according to the error message.

Hi Erel,
Yes i posted the line (24) where the error raised.
I avoided this error using instead: Callsub ("ModuleToggle","Testbouton")
Many thanks.
 
Upvote 0
Top