Hi !
Could you help me to convert this code to b4a native commands !
Thanks !
i've this
But not works...
Thanks for the help !
Could you help me to convert this code to b4a native commands !
Thanks !
B4X:
'Function Wrapper$(Var$,width)
' While Var <> ""
' result$ = ""
' ;if length of string Is greater than our width
' If Len(Var) > width
' spotcheck = width
' char$ = ""
' ;Look For the last space in our Next 'width chunk' of the MasterText
' Repeat
' spotcheck = spotcheck - 1
' char = Mid(Var,spotcheck,1)
' Until char = " " Or spotcheck = 0
' ;didn't find a space
' If spotcheck = 0
' result = Left(Var,width)
' Var = Right(Var,Len(Var) - width)
' ;found a space
' Else
' result = Left(Var,spotcheck - 1)
' Var = Right(Var,Len(Var) - spotcheck)
' EndIf
' ;length of string Is less than Return width so send it all back
' Else
' result=Var
' Var=""
' EndIf
' Print result
' Wend
'End Function
i've this
B4X:
Sub WordWrap(Texte As String, Largeur As Int) As String
Dim Resultat As String
Dim spotcheck As Int
Dim Caractere As String
Do While Texte <> ""
Resultat = ""
'if length of string Is greater than our Largeur
If Texte.Length > Largeur Then
spotcheck = Largeur
Caractere = ""
'Look For the last space in our Next 'Largeur chunk' of the MasterText
Do While Caractere = " " Or spotcheck = 0
spotcheck = spotcheck - 1
Caractere = Texte.SubString2(spotcheck,1)
Loop
'didn't find a space
If spotcheck = 0 Then
Resultat = Texte.substring2 (0, Largeur)
Texte = Texte.substring2 (Texte.Length - Largeur, Texte.Length)
'found a space
Else
Resultat = Texte.SubString2 (0,spotcheck - 1)
Texte = Texte.SubString2 (Texte.Length - spotcheck, Texte.Length)
End If
'length of string Is less than Return Largeur so send it all back
Else
Resultat=Texte
Texte=""
End If
Return Resultat
Loop
End Sub
Thanks for the help !