Android Tutorial [B4X] Clipper FoxPro Xbase++ Functions

Discussion in 'Tutorials & Examples' started by AnandGupta, Oct 23, 2018.

  1. AnandGupta

    AnandGupta Active Member Licensed User

    When I started again developing in B4A, I looked around my developed desktop applications to make something similar, as I will know what the result should be.

    I choose my small attendance program written Xbase++ (similar to Clipper/FoxPro). It is a very simple coded, with saving the current date and time, for selected person, in DBF file, sending email with current month records and also sending SMS using SMS server url of company.

    While making/converting the codes, I stuck at many places but each time I managed to solve it by just searching our Forum. I sincerely thank all our members for providing solutions for trivial to complex problems.

    As I progressed, I found that it would be easier for me to cut and paste most codes from Xbase++ to B4A, with minimum changes if I can have the similar functions in B4A.

    I made some functions as I needed. I intend to increase it as I develop more. I have attached the text file of the same.

    Code:
    Sub space(nLen As Int) As String
        
    Dim cTxt As StringBuilder

        cTxt.Initialize
        
    For i = 1 To nLen
            cTxt.Append(
    " ")
        
    Next

        
    Return cTxt.ToString
       
    End Sub

    Sub len(cTxt As StringAs Int
       
        
    Return cTxt.Length
       
    End Sub

    Sub CMonth(mDT As Long) As String
       
        
    Return DateUtils.GetMonthName(mDT)
       
    End Sub

    Sub year(mDT As Long) As Long
       
        
    Return DateTime.GetYear(mDT)
       
    End Sub

    Sub str(nNum As Long, nLen As Int) As String
        
    Dim cTxt As String
        
    Dim cTxt2 As StringBuilder
        
    Dim nLen2 As Int

        cTxt = nNum
        nLen2 = nLen - cTxt.Length
        cTxt2.Initialize
        
    For i = 1 To nLen2
            cTxt2.Append(
    " ")
        
    Next

        
    Return cTxt2 & cTxt

    End Sub

    Sub Replicate(Chars As String, Num As Int) As String
        
    Dim cTxt As StringBuilder

        cTxt.Initialize
        
    For i = 1 To Num
            cTxt.Append(Chars)
        
    Next

        
    Return cTxt.ToString

    End Sub

    Sub pad(cTxt As String, nLen As Int) As String
        
    Dim cTxt2 As StringBuilder
        
    Dim nLen2 As Int

        cTxt2.Initialize
        nLen2 = nLen - cTxt.Length
        
    If nLen2 > 0 Then
            
    For i = 1 To nLen2
                cTxt2.Append(
    " ")
            
    Next
        
    Else
            cTxt2.Append(
    "")
            cTxt = cTxt.SubString2(
    0, nLen)
        
    End If


        
    Return cTxt & cTxt2.ToString
       
    End Sub

    Sub Day(mDT As Long) As Int
        
    Dim cTxt As String
        
    Dim nNum As Int
       
        cTxt = mDT
        cTxt = cTxt.SubString2(
    0,2)
        nNum = cTxt
       
        
    Return nNum
       
    End Sub

    Sub trim(cTxt As StringAs String

        
    Return cTxt.Trim()
       
    End Sub

    Sub strtran(cTxt As String, cSearch As String, cReplace As StringAs String

        
    Return cTxt.Replace(cSearch, cReplace)
       
    End Sub

    Sub upper(cTxt As StringAs String

        
    Return cTxt.ToUpperCase()
       
    End Sub

    Sub lower(cTxt As StringAs String

        
    Return cTxt.ToLowerCase()
       
    End Sub
    It is my thank you to the members of our Community.

    If you find errors, please tell me. Also will be happy for better suggestion.

    Regards,

    Anand
     

    Attached Files:

    Erel, Myr0n, AHilton and 1 other person like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    I've added [B4X] to the thread title as your code will also work in B4J and B4i.
     
    AnandGupta likes this.
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