Android Question Problems with CallSub

clooney48

Active Member
Licensed User
Longtime User
Hi!

Ich have an activity called "Settings" where I fill some variables (defined in Process_Globals). So when I start the main activity I want to execute in Activity_Create the sub "PrepareStrings" of Settings and get the value of the variable "sJa" which is defined in the sub "PrepareStrings". But the debugger shows that the sub "PrepareStrings" isn´t called.

'Main
B4X:
Sub Activity_Create(FirstTime As Boolean)
...   
    CallSub(Settings, "PrepareStrings")
    Msgbox(Settings.sJa,"")
end Sub
 

clooney48

Active Member
Licensed User
Longtime User
It seems you have arguments on that sub, please post your code to better understand what's going on.
Yes, I forgot the argument in the sub. Now I get the result. But it is not clear to me how to get the content of the other variables like "sJa" etc in Main from Settings. I thought I could see it for example with: msgbox(Settings.sJa,"")!? But nothing and apparently the code doesn´t get on after "Msgbox(Settings.sJa,"")" because the screen is black?? Perhaps a missing library for the line " r.RunStaticMethod("java.util.Locale", "getDefault", Null, Null)"?

The original intention is only to run the Settings when Main is startet that I can get the different variables "sJa", "sNein" etc. for the procedure in the Main.
B4X:
'Main
Sub Activity_Create(FirstTime As Boolean)
.....
    CallSubDelayed2(Settings, "PrepareStrings", "")
    Msgbox(Settings.sJa,"")
    Activity.LoadLayout("StartView")
End Sub
---------------------------
'Settings
Sub PrepareStrings(Title As String)

  If Language = "" Then
  Dim r As Reflector
  r.Target = r.RunStaticMethod("java.util.Locale", "getDefault", Null, Null)
  Language = r.RunMethod("getLanguage")
   Msgbox(Language,"")
  End If

  Select Case Language
  Case "de": PrepareStringsDE
  Case Else: PrepareStringsEN: Language = "en"
  End Select

End Sub

Sub PrepareStringsDE
  sJa = "Ja"
  sNein = "Nein"
  sEin = "Ein"
  sAus = "Aus"
  '...
End Sub

Sub PrepareStringsEN
  sJa = "Yes"
  sNein = "No"
  sEin = "On"
  sAus = "Off"
  '...
End Sub
 
Last edited:
Upvote 0

clooney48

Active Member
Licensed User
Longtime User
CallSubDelayed is opening the Settings activity and staying there, if you just want to assign values to variables, then use a code module instead of an activity module.
Hi NJDude!

I understand! Works perfect now!
Thanks a lot!
 
Upvote 0
Top