J jkhazraji Active Member Licensed User Longtime User Sep 1, 2023 #1 Hi B4X community, I have the following as a part of a Java code in a class: B4X: #if Java { // //.... String msg ="blabla"; ba.raiseEvent(null,"get_msg",msg); //..... // } #end if Is the ba.raiseEvent written correctly? How would I expose 'msg' variable to the main module of the b4j app and use it there ? Last edited: Sep 1, 2023
Hi B4X community, I have the following as a part of a Java code in a class: B4X: #if Java { // //.... String msg ="blabla"; ba.raiseEvent(null,"get_msg",msg); //..... // } #end if Is the ba.raiseEvent written correctly? How would I expose 'msg' variable to the main module of the b4j app and use it there ?
J jkhazraji Active Member Licensed User Longtime User Sep 1, 2023 #2 And there was silence, I was able to do it by reading and digging in the forum using multiple parameters: Edited: 1- Inside the inline Java code: B4X: #If Java String msg1="I am message no. 1"; String msg2="I am message no. 2"; anywheresoftware.b4a.objects.collections.Map Params = new anywheresoftware.b4a.objects.collections.Map(); Params.Initialize(); Params.Put("msg1",msg1); Params.Put("msg2",msg2); ba.raiseEvent(this, "get_msgs", new Object[]{Params}); #end if 2- Construct the Sub inside the class: B4X: Private Sub get_msgs(Params as Map) CallSubDelayed2(Main,"getData",Params) End Sub 3- In the Main module: B4X: Private Sub getData(Params As Map) Log("By CallSubDelayed2:") Log($"${Params.Get("msg1")}"$) Log($"${Params.Get("msg2")}"$) End Sub Hope it is of general benefit. Last edited: Sep 1, 2023 Upvote 0
And there was silence, I was able to do it by reading and digging in the forum using multiple parameters: Edited: 1- Inside the inline Java code: B4X: #If Java String msg1="I am message no. 1"; String msg2="I am message no. 2"; anywheresoftware.b4a.objects.collections.Map Params = new anywheresoftware.b4a.objects.collections.Map(); Params.Initialize(); Params.Put("msg1",msg1); Params.Put("msg2",msg2); ba.raiseEvent(this, "get_msgs", new Object[]{Params}); #end if 2- Construct the Sub inside the class: B4X: Private Sub get_msgs(Params as Map) CallSubDelayed2(Main,"getData",Params) End Sub 3- In the Main module: B4X: Private Sub getData(Params As Map) Log("By CallSubDelayed2:") Log($"${Params.Get("msg1")}"$) Log($"${Params.Get("msg2")}"$) End Sub Hope it is of general benefit.