For all who like the old traditional Basic String functions ....
Just save the following code as "string.bas" and include it to your project as needed ...
String functions are:
String.Mid(a$,x,y)
String.Left(a$,x)
String.Right(a$,x)
String.Parsecount(a$,b$)
String.Parse(a$,b$,x)
G.
Just save the following code as "string.bas" and include it to your project as needed ...
String functions are:
String.Mid(a$,x,y)
String.Left(a$,x)
String.Right(a$,x)
String.Parsecount(a$,b$)
String.Parse(a$,b$,x)
G.
B4X:
Type=StaticCode
Version=2.22
@EndOfDesignText@
Sub Process_Globals
End Sub
Sub Mid(string_expression As String,start As Int,length As Int) As String
If start+length-1>string_expression.length Then
length=string_expression.length+1-start
End If
If start-1>string_expression.length Then
Return ""
Else
Return string_expression.SubString2(start-1,start+length-1)
End If
End Sub
Sub Left(string_expression As String,length As Int) As String
If length>string_expression.length Then
length=string_expression.length
End If
Return string_expression.SubString2(0,length)
End Sub
Sub Right(string_expression As String,length As Int) As String
If length>string_expression.length Then
length=string_expression.length
End If
Return string_expression.SubString2(string_expression.length-length,string_expression.length)
End Sub
Sub parsecount(string_expression1 As String,string_expression2 As String) As String
Dim z As Int
Dim c As Int
c=0
For z=1 To string_expression1.Length
If Mid(string_expression1,z,string_expression2.Length)=string_expression2 Then
c=c+1
End If
Next
Return c+1
End Sub
Sub parse(string_expression1 As String,string_expression2 As String,count As Int)
Dim c As String
Dim po,p1,p2,z As Int
If count>parsecount(string_expression1,string_expression2)+1 Then Return
c=string_expression2 & string_expression1 & string_expression2
po=0
For z=1 To c.Length
If Mid(c,z,string_expression2.Length)=string_expression2 Then
po=po+1
End If
If po=count Then
Exit
End If
Next
p1=z
For z=p1+1 To c.Length
If Mid(c,z,string_expression2.Length)=string_expression2 Then
Exit
End If
Next
p2=z
Return Mid(c,p1+string_expression2.Length,p2-p1-string_expression2.Length)
End Sub