B4A Library String Functions

Discussion in 'Additional libraries, classes and official updates' started by margret, Jul 22, 2011.

  1. appie21

    appie21 Active Member Licensed User

    Many thanks!
     
  2. PierreK

    PierreK New Member

    Hello,

    if I want to debug the app I got this error :(
    Can anyone help me please. I can't find anything about this issue in google or the forum...

    Code:
    *** Remote compilation mode ***
    B4A version: 
    5.02 (1)
    Parsing code.    (
    0.01s)
    Compiling code.    (
    0.09s)
    Compiling layouts code.    (
    0.02s)
    Compiling debugger engine code.    (
    1.36s)
    Sending data 
    to remote compiler.    Error
    step: Compiling generated Java code.
    javac 
    1.7.0_09
    src\b4a\example\main.java:
    343: error: package adr.stringfunctions does not exist
    public adr.stringfunctions.stringfunctions _sf = null;
                              ^
    Note: src\b4a\example\httputils2service.java uses 
    or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation 
    for details.
    1 error
    Thanks
    Pierre
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The remote builder used with the trial version doesn't include this library.
     
    DonManfred likes this.
  4. PierreK

    PierreK New Member

    Ohh ok, thanks.
     
  5. Arun

    Arun Member Licensed User

    I have developed and tested an app in the last few days and it was ready for demonstrating to a potential customer.

    I had an issue with the progress bar yesterday, for which a new thread was created. In the meantime, I wanted to insert some more features.

    Now, suddenly this message is appearing and I cant work any further on this app.

    Code:
    *** Remote compilation mode ***
    B4A version: 
    5.02 (1)
    Parsing code.    (
    0.03s)
    Compiling code.    (
    0.17s)
    Compiling layouts code.    (
    0.00s)
    Compiling debugger engine code.    (
    1.01s)
    Sending data 
    to remote compiler.    Error
    step: Compiling generated Java code.
    javac 
    1.7.0
    src\b4a\example\main.java:
    348: error: package adr.stringfunctions does not exist
    public adr.stringfunctions.stringfunctions _strfunc = null;
                              ^
    1 error
    Does it mean I cannot use the stringfunctions library in the Trial version?

    Please let me know asap, as I will have to start my app from scratch.

    Thanks
     
  6. DonManfred

    DonManfred Expert Licensed User

    Yes. With the Trial you cannot use additional Libraries. You need a fullversion for this.
     
    lemonisdead likes this.
  7. Arun

    Arun Member Licensed User

    I have downloaded the Trial version on 17th July and have spent the last 5 days working on this app (including the weekend)

    The app was successfully tested using remote compilation to devices belonging to other members of my team. Not ONCE did this error come up, till now.

    Isn't there any indication of what libraries can/cant be used in the Trial version? The Trial Version of B4A 2.0 which i had used 3 years ago was very specific about which libraries could and couldn't be used. I had then purchased the full version for 2 years.

    Anyways, I am now wondering whether to pursue developing this app further. I wish this error had come in the beginning itself, then i would have known what restrictions I was working with.

    Once again, thanks for the prompt reply.
     
  8. Prosg

    Prosg Active Member Licensed User

    hello
    Maybe i find a bug with mid function:

    Code:
    Dim str as string = "0900-1800"

    Dim result as string = sf.mid(str, 5,2)
    log (result)

    'Bug : result return -1
     
  9. DonManfred

    DonManfred Expert Licensed User

    The 5. char is "-"
    The 6th char is "1"

    sf.mid(str, 5,2) results in "-1"

    Not a error!
     
    spairo likes this.
  10. Prosg

    Prosg Active Member Licensed User

    xd i'm too tired ================> i go sleeping :)
     
  11. vbmundo

    vbmundo Well-Known Member Licensed User

    Hi,

    I have problems with your SPLIT function

    Look

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
       
        
    Dim TextoEncriptado As String, Texto As String, valores As List 
       
        SF.Initialize
       
        Telefono.SetScreenOrientation(
    1)
        
    Activity.LoadLayout("Principal")
        
    Activity.Title="Super MySQL"
        
    If File.Exists(Carpeta,"reg5.smql")=True Then
           TextoEncriptado=
    File.ReadString(Carpeta,Archivo)
           Texto=Decrypt(TextoEncriptado)
           valores=SplitMe(Texto,
    "|")
           txtServidor.Text=valores.Get(
    0)
           txtPort.Text=valores.Get(
    1)
           txtUser.Text=valores.Get(
    2)
           txtPassword.Text=valores.Get(
    3)
        
    End If
    End Sub

    Sub SplitMe(S As String,Delimiter As StringAs List
    Dim SF As StringFunctions
    SF.Initialize
    Return SF.Split(S,Delimiter)
    End Sub
    I have (for example.) this TEXT

    "VALUE 1|XXXXXXX|YYYYYYYYY|GGGGGG"

    And the Split function doesn'tretunt a WORD, only return the first Character.

    What's Wrong ?

    Regards
     
  12. LucaMs

    LucaMs Expert Licensed User

    The character "|" (Pipe) is a special character, then you should add a Backslash before it:
    Code:
    Dim lstWords As List
    lstWords = SplitMe(
    "VALUE 1|XXXXXXX|YYYYYYYYY|GGGGGG""\|")

    For i = 0 to lstWords.Size - 1
        
    Log(i & Tab & lstWords.Get(i))
    Next


    Sub SplitMe(S As String, Delimiter As StringAs List
        
    Dim SF As StringFunctions
        SF.Initialize
        
    Return SF.Split(S, Delimiter)
    End Sub
     
    lemonisdead likes this.
  13. LA3QMA

    LA3QMA Member Licensed User

    I need some help with the mid() function.

    Code:
    tekst = "111110000101001001101000001010"
    Log(tekst.Length)

    For x = 1 To tekst.Length Step 8
       
    Log(sf.Mid(tekst, x, 8))
    Next
    I'm getting a result like:
    11111000
    01010010
    01101000

    But i'm expecting:
    11111000
    01010010
    01101000
    001010

    How can i easily fix this?
     
  14. DonManfred

    DonManfred Expert Licensed User

    i´m not familar with this library...

    Usually in b4a it starts with 0
    not sure but have you tried to start at 0?
    Code:
    For x = 0 To tekst.Length-1 Step 8
     
  15. LA3QMA

    LA3QMA Member Licensed User

    DonManfred: yes i tried starting at 0 but this is not working. And yes several languages are not consistent on whats starting with 0 or 1 so i have tried both.
     
  16. klaus

    klaus Expert Licensed User

    It seems that the Mid functionality is not the same as in VB.
    In VB if the rest of the string is smaller than the given length Mid returns the rest.
    The Mid function in the B4A StringFunction library doesn't.
    The StringFunction library was at the beginning a code module.
    There were several versions. I have one of those old ones, but not a recent one, and at this time the function was this:
    Code:
    Sub Mid(Text As String, Start As Int, Length As Int) As String
        
    Return Text.SubString2(Start - 1, Start + Length - 1)
    End Sub
    This shows that the rest will not be returned.
    The code module was later compiled to a library and no source code anymore.

    You could change your code to this one:
    Code:
    Dim tekst = "111110000101001001101000001010" As String
    Log(tekst.Length)

    For x = 1 To tekst.Length Step 8
        
    If tekst.Length - x + 1 < 8 Then
            
    Log(sf.Mid(tekst, x, tekst.Length - x + 1))
        
    Else
            
    Log(sf.Mid(tekst, x, 8))
        
    End If
    Next
    Or to this using the B4A native function:
    Code:
    For x = 0 To tekst.Length - 1 Step 8
        
    If tekst.Length - x < 8 Then
            
    Log(tekst.SubString2(x, tekst.Length))
        
    Else
            
    Log(tekst.SubString2(x, x + 8))
        
    End If
    Next
    Or this shorter one.
    Code:
    For x = 0 To tekst.Length - 1 Step 8
        
    Log(tekst.SubString2(x, Min(x + 8, tekst.Length)))
    Next
     
  17. LA3QMA

    LA3QMA Member Licensed User

    Thank you this solved my issue. Going for the shorter one :)
     
  18. westingenieria

    westingenieria Active Member Licensed User

    hello Margret, you can upload the source code creating libraries please. thank you very much.
     
  19. Johan Schoeman

    Johan Schoeman Expert Licensed User

    You can very easily do this with inline Java code - see the attached project and specifically the class StringUtilities
     

    Attached Files:

    Mashiane likes this.
  20. mototest

    mototest New Member Licensed User

    Hi
    I have problem with example
    Code:
    Dim text, pattern As String
    text = 
    "any text*any text*any text*"
    pattern = 
    "*" 'one or more digits
    Dim Matcher1 As Matcher
    Matcher1 = 
    Regex.Matcher(pattern, text)
    Do While Matcher1.Find
      
    Log("Found: " & Matcher1.Match)
    Loop
    When pattern is any character then works ok, but when I search "*" then compiler give below error, why ?

    java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 1:

    Generally I want find all position "*" in string and extract text between two stars : *text*

    Thanks
    Boguslaw
     
    Last edited: Sep 15, 2016
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice