problem with process_global variable

Spacewalker

Member
Licensed User
Longtime User
Hello,

I have a problem with global variables:

I have 2 modules:
Main
Activity2

in Main I declare a process_global variable "iTXTSize" as follows:
Code: Copy
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   
   Dim iTXTSize As Int
End Sub
and also in Main I assign a value to iTXTSize and call another Activity like this:
Code: Copy
Sub btnSizeOK_Click
   iTXTSize = txtSize.text
    CallSubDelayed (Activity2,"StartProg")
End Sub
in Activity2 I want to use the process_global variable iTXTSize:
Code: Copy
sub StartProg()
Msgbox ("Activity2: Size="& iTXTSize,"") 'here ERROR
end sub
But I get an error:
Error description: Undeclared variable 'itxtsize' is used before it was assigned any

Why is this?
I thought that a process_global variable should be available in all modules?

thx
Heinz
 
In fact, you need:

Code: Copy
sub StartProg()
     Msgbox ("Activity2: Size="& numberformat2(main.iTXTSize,1,0,0,false),"")
end sub

In Msgbox, you can only use strings,

Regards,

Edgar
 
Upvote 0
In Msgbox, you can only use strings,
Only partly true. Basic4android will convert any non-string types for you using the ToString() method of that type. It will do this anywhere and not only where strings are expected, it will try to convert any type to the expected type.
 
Upvote 0
Back
Top