Wish Magret'StringFunction is supported for B4A,B4J,B4i for non-expert coding person as me

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
Is there way re-engineer the Magret'sStringFunction2 ? I know only it created by B4A. I used to see the sourcecode once the time.
The library is necessary for helping easy coding more times.
https://www.b4x.com/android/help/stringfunctions.html#stringfunctions_at

Please add Erel's Function,too.
B4X:
'only tested with positive numbers
Private Sub FormatWithCustomGrouping(n As Double, DecimalPoints As Int) As String
    Dim Groupings() As Int = Array As Int(3, 2, 1000)
    Dim res As StringBuilder
    res.Initialize
    Dim i As Int = n
    Dim s As String = i
    Dim f As Double = (n - i) * Power(10, DecimalPoints)
    res.Insert(0, NumberFormat2(f, DecimalPoints, 0, 0, False))
    res.Insert(0, ".")
    Dim index As Int = s.Length - 1
    For Each g As Int In Groupings
        Do While g > 0
            If index < 0 Then Exit
            res.Insert(0, s.CharAt(index))
            g = g - 1
            index = index - 1       
        Loop
        If index >= 0 Then res.Insert(0, ",")
    Next
    Return res.ToString
End Sub

Best Regards
Theera
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
What you want to do?
You can just use NumberFormat2 or B4XFormatter.
I saw Erel's code ,I think it is interesting. The really,I need Margret's StringFunction be supported for all of platform. Altrough Margret's library is the old,but it's one of infrastructure library should have in B4A,B4i,B4J.
 

aeric

Expert
Licensed User
Longtime User
If you want to make that class B4X cross platform then you can add something like #If B4A then code specific to B4A will not supported in B4J. That's all.
 

Theera

Well-Known Member
Licensed User
Longtime User
If you want to make that class B4X cross platform then you can add something like #If B4A then code specific to B4A will not supported in B4J. That's all.
Now,I don't know how to re-engineering Margret's StringFunction. And I don't have B4i.
 

Theera

Well-Known Member
Licensed User
Longtime User
Create your own class or b4xlib.
If the functions only use StringUtils then should be no issue if you just add iStringUtils inside the manifest file.
The present, Margret'String function is never have before. I don't know to start it.
 

Theera

Well-Known Member
Licensed User
Longtime User
The present, Margret'String function is never have before. I don't know to start it.
In creating B4XLib,if the file folder has the files (fonts files) in special folder in B4i. I must add the special folder too,or not?
 
Top