IDEA: Pure java in-code....

JohnK

Active Member
Licensed User
Longtime User
I was wondering, would it be possible to have "regions" of code that would not be interpreted by the conversion from Basic into Java, and simply be copied "as is" directly into the Java code before compilation? I would think it would be an alternative to reflection, especially for multiple lines of Java.

I was thinking of something similar to the current "#Region" feature; maybe something like:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim _mcur_game_mode As String
   If FirstTime Then
#Java
      if ((_mcur_game_mode).equals("")) 
         { 
            _mcur_game_mode = "Standard";
         };
#End Java
      pnlLayer.Initialize("pnlLayer")
      Activity.AddView(pnlLayer, 0, 0, 100%x, 100%y)
      cvsLayer.Initialize(pnlLayer)
   End If
End Sub
The above is useless in itself, but I think the idea would be very powerful. At this stage, I do not have a need for it, its just an idea.
 
Last edited:

Penko

Active Member
Licensed User
Longtime User
First of all, you should take in account that what you type in Basic is NOT what you get in Java. In addition to converting your Basic code, the B4A compiler also does the object casting for you. Moreover, it includes a powerful exceptions manager allowing you to get a decent error message rather than "The app needs to close" or whatever.

I assume in certain conditions, your idea may break the compiler.
 
Top