Android Tutorial [B4X] Clipper FoxPro Xbase++ Functions

AnandGupta

Well-Known 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.

B4X:
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 String) As 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 String) As String

    Return cTxt.Trim()
   
End Sub

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

    Return cTxt.Replace(cSearch, cReplace)
   
End Sub

Sub upper(cTxt As String) As String

    Return cTxt.ToUpperCase()
   
End Sub

Sub lower(cTxt As String) As 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
 

Attachments

Top