Bal2Bjl - Deprecated - see post #1

stevel05

Expert
Licensed User
Longtime User
Following on from Erel and @Filippo 's work, I have spent a little time and added some functionality to the code. I have tried it with some very old and complex B4a layouts and it seems to work, but I'm sure there will be some issues along the way.

If it doesn't work first time, try saving the B4a layout with a newer version.

If the layout contains custom views, don't forget to create the custom view class module. It can be empty until you are ready to rewrite it, but it needs to be there for the layout to display.

There is still some logging in the code, which I will leave for now.

Let me know if it works for you.

Hope it helps.

Update 0.2 added a missing Drawable variant.

Note: this utility is now redundant as you can copy and paste layouts between IDE's on different platforms which is much easier.


0.2 : 54
 

Attachments

  • Bal2Bj0-2.zip
    9.9 KB · Views: 528
Last edited:

stevel05

Expert
Licensed User
Longtime User
Fixed Scrollview Implementation and added default entries for MaterialIcons and FontAwesome
 

stevel05

Expert
Licensed User
Longtime User
Update to v0.2 added missing Drawable variant.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I am trying to convert the attached file and it crashes:
B4X:
Waiting for debugger to connect...
Program started.
D:\AndroidProjects\MusicDB\Files
D:\B4J\MusicDB\Files
*** NewFile ************
Bal2Bjl version 0.03
error padding
error padding
error padding
error padding
error drawable
Error occurred on line: 308 (BalConverter)
java.lang.ArrayIndexOutOfBoundsException: 268435456
   at b4j.example.balconverter._readcachedstring(balconverter.java:854)
   at b4j.example.balconverter._readmap(balconverter.java:445)
   at b4j.example.balconverter._readmap(balconverter.java:478)
   at b4j.example.balconverter._readmap(balconverter.java:478)
   at b4j.example.balconverter._readmap(balconverter.java:478)
   at b4j.example.balconverter._readmap(balconverter.java:478)
   at b4j.example.balconverter._convertbaltojsoninmemory(balconverter.java:136)
   at b4j.example.main._btnconvert_action(main.java:260)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
   at anywheresoftware.b4a.BA$1.run(BA.java:215)
   at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
   at java.security.AccessController.doPrivileged(Native Method)
   at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
   at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
   at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
   at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
   at java.lang.Thread.run(Thread.java:745)

Line 308 is:
B4X:
Private Sub ReadCachedString(raf As RandomAccessFile, cache() As String) As String
   If cache.Length = 0 Then Return ReadString(raf)
   Return cache(raf.ReadInt(raf.CurrentPosition))
End Sub
 

Attachments

  • sprocessor.bal
    14.7 KB · Views: 348

stevel05

Expert
Licensed User
Longtime User
Is it a new layout or from an old project?
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I am using 7.01 of B4A and just verified that I edited the screen and saved it to make sure it was updated.

Still same crash
 

stevel05

Expert
Licensed User
Longtime User
This may take some time, there is something on the layout that is not being parsed correctly. The easiest way to find it will be to remove the views one at a time until it starts to work. I am not going to have much time for programming this weekend, if you would like to try it then feel free. If not, I will have a go probably on Tuesday.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Well, turns out I had Padding checked on 2 label fields and set to 5, 0, 0, 0

Padding doesn't exist - NOT sure how to modify the program to handle padding.
 

stevel05

Expert
Licensed User
Longtime User
Easiest thing would be to remove the padding, it would be ignored on the import anyway. You'll probably have to set it using cssutils.
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Exactly what I did. But for the future it would be nice if the program did that.

But works GR8

Thanks
 

stevel05

Expert
Licensed User
Longtime User
I'll take a look, but I'm not sure how to do that. It's Erel's code that parses the layout.
 

ilan

Expert
Licensed User
Longtime User
nice work @stevel05. can it also do bjl2bal ? just finished a b4j project and would like to convert the layouts to bal files.
thanx
 

stevel05

Expert
Licensed User
Longtime User
No I'm afraid not.
 

stevel05

Expert
Licensed User
Longtime User
@Erel Please add this to your list of posts to archive it may help to avoid confusion.

Thanks
 
Top