Android Question Is there a posibility creating B4XLib file this straty

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
I 'm interested in creating B4XLib. I have the idea different from others about creating B4XLib.
I still have the problem how to create B4XStringFunctionVB and B4XThaiUtils in B4J.
Assume I have created X.jar and X.xml in B4A , jX.jar and jX.xml in B4J and in B4i I can do as the same stragies.(I don't have B4i) (iX.jar and iX.xml)

From Fiplipo's CreateB4XLib stratgy . we need layouts in File folder ,manifest.txt file and X.Bas file.

In X.Bas file I copy each Bas file in B4A,B4J,B4i and using #If B4A..<bas in b4a>. ..#End IF Block ,#If B4J...<bas in b4j>...#End If Block and #If B4i...<bas in b4i>....#End If Block

I don't know that It can be ...



Best Regards,
Theera
 
Last edited:

ilan

Expert
Licensed User
Longtime User
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Not all b4xlib need to have layout file. If no UI views involved, no need to add layout file. The file can just contain one x.bas file. The manifest.txt file is also optional.
I mean that. Include bas file in b4a,bas file in b4j and bas file b4i into one file. Perhaps,we can convert all of the old libs into one b4xlib. @SD Star-Dust expert always create separated libraries,and I notice xui in manifest.txt are differ.
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Tips for you:
  1. If the b4xlib does not use UI, No need to add XUI or XUI Views dependencies (B4J.DependsOn=jXUI,XUI Views and B4A.DependsOn=XUI,XUI Views)
  2. If the b4xlib does not use UI, No need to add layout files
  3. If you don't have B4i, No need to add B4i dependencies (Supported Platform=B4A,B4J in manifest.txt)
  4. If you don't need working with files, No need to use setDataFolder
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Tips for you:
  1. If the b4xlib does not use UI, No need to add XUI or XUI Views dependencies (B4J.DependsOn=jXUI,XUI Views and B4A.DependsOn=XUI,XUI Views)
  2. If the b4xlib does not use UI, No need to add layout files
  3. If you don't have B4i, No need to add B4i dependencies (Supported Platform=B4A,B4J in manifest.txt)
  4. If you don't need working with files, No need to use setDataFolder
I need to learned the code. I understand English not very well. So I need the example for me study. While I need Thai developlers in here,I don't know to ask anyone.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Use Google translate.
Don't repeat and remind yourself that you are not good, you will become not good.
Just try to explain as much as you can.
Google translate can translate in Thai correctly only 30 %
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Better than nothing
Do mind to see my code B4XThaiUtils and B4XStringfunctionVB for me. B4XStringFunction come from Magret's lib. Its working with the file. I have tried to do as Alexander's advice. But it still has error. I no idea to continue how make it work. Sometimes,I 'm burnt out to learn b4x. I'm here 12 years,but looks like me be here only 3 days.
Best Regards,
Theera
 
Upvote 0

emexes

Expert
Licensed User
Perhaps,we can convert all of the old libs into one b4xlib.

Perhaps start simple. One step at a time. Walk before you run (or crawl before you walk).

Create a library with just one super-simple function, for example:

B4X:
Sub Hello(YourName As String) As String

    Return "Hello, " & YourName
    
End Sub

Once you've got that going, then add a second function to the library, for example:

B4X:
Sub LookingGood(YourName As String) As String

     Return "If you can read this then the B4XLIB by " & YourName & " is looking good!"

End Sub

and from that point onwards it should be plain sailing.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I've tried to translate Klaus'B4XGettingStarted
,but I need more times to learn the code for unstanding.
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I see two problems in your B4XLIB code in your B4XStringfunctionVB library.

First relates to B4J which doesn't have File.DirInternal available - you could try the following.

B4X:
Public Sub Initialize
    DataFileName = "Data_Temporary_File.map"
   
    #if b4j
        DataPathName = File.DirApp
    #else
        DataPathName = File.DirInternal
    #End If
End Sub

Second is that almost all of your sub routines are not public.

instead of [Edit] (For all subs)

B4X:
Sub AddSpaces (HowMany As Int) As String

change to

B4X:
Public Sub AddSpaces (HowMany As Int) As String

See attached lib with modifications. Tested in B4J
 

Attachments

  • B4XStringFunctionVB.b4xlib
    5.7 KB · Views: 67
Last edited:
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I've
I see two problems in your B4XLIB code in your B4XStringfunctionVB library.

First relates to B4J which doesn't have File.DirInternal available - you could try the following.

B4X:
Public Sub Initialize
    DataFileName = "Data_Temporary_File.map"
   
    #if b4j
        DataPathName = File.DirApp
    #else
        DataPathName = File.DirInternal
    #End If
End Sub

Second is that almost all of your sub routines are not public.

instead of

B4X:
Sub AddSpaces (HowMany As Int) As String

change to

B4X:
Public Sub AddSpaces (HowMany As Int) As String

See attached lib with modifications. Tested in B4J
I've edited.But I 've just post my code. Thank you for your reply.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I see (think) you are creating multiple b4xlib.

Another tips for you:
  1. Create a B4J project and add simple class name B4XLibA.bas
  2. If your library is not using any UI views or just pure String functions, just create non-UI project in B4J
  3. Follow my tips in post #6 above
  4. Use Winzip or WinRAR to save the B4XLibA.bas inside a zip file and rename the file as B4XLibA.b4xlib
  5. If everything okay, put B4XLibA.b4xlib into your Additional Library folder inside B4X folder
To create a second library that depends on the library above:
  1. Create a new project in B4J by repeating the steps above
  2. Check the B4XLibA library from Libraries Manager
  3. Add a class B4XLibB.bas where you will use some functions from B4XLibA
  4. Create the B4XLibB.b4xlib
Now let say I want to create a project that uses B4XLibB which depends on B4XLibA, I just need to check both libraries in Libraries Manager.

1694683702147.png


Once B4J is working, make it works in B4A.

Optionally, you can also make it works for B4i without B4i.

Why I use B4J to develop?
Because I don't need to use a device or emulator for testing at early stage.
 

Attachments

  • B4XLibA.zip
    937 bytes · Views: 70
  • B4XLibB.zip
    989 bytes · Views: 69
  • B4XLibDemo.zip
    14 KB · Views: 68
  • B4XLibA.b4xlib
    479 bytes · Views: 59
  • B4XLibB.b4xlib
    531 bytes · Views: 68
Upvote 0
Top