@Left, @Right, @Leftback, @Rightback, And @Word @Functions

Here are the LotusScript equivalents for the @Left, @Right, @LeftBack,
@RightBack, and @Word @functions
.

Function Left (sourceString As String, searchString As String) As String
pos% = Instr(sourceString, searchString)
If pos% > 0 Then pos% = pos% -1
Left = Left(sourceString, pos%)
End Function

Function Right (sourceString As String, searchString As String) As String
pos% = Instr(sourceString, searchString)
length% = Len(sourceString)
start% = length% - pos%
Right = Right(sourceString, start%)
End Function

Function LeftBack (sourceString As String, searchString As String) AsString
For i% = Len(sourceString) To 1 Step -1
sourceStringBack$=sourceStringBack$ & Mid(sourceString, i%, 1)
Next
For i% = Len(searchString) To 1 Step -1
searchStringBack$=searchStringBack$ & Mid(searchString, i%, 1)
Next
pos% = Instr(sourceStringBack$, searchStringBack$)
length% = Len(sourceStringBack$)
start% = length% - pos%
result$ = Right (sourceStringBack$, start%)
For i% = Len(result$) To 1 Step -1
turn$=turn$ & Mid(result$, i%, 1)
Next
LeftBack=turn$
End Function

Function RightBack (sourceString As String, searchString As String) As String
For i% = Len(sourceString) To 1 Step -1
sourceStringBack$=sourceStringBack$ & Mid(sourceString, i%, 1)
Next
For i% = Len(searchString) To 1 Step -1
searchStringBack$=searchStringBack$ & Mid(searchString, i%, 1)
Next
pos% = Instr ( sourceStringBack$, searchStringBack$)
If pos% > 0 Then pos% = pos% - 1
result$ = Left ( sourceStringBack$, pos%)
For i% = Len(result$) To 1 Step -1
turn$=turn$ & Mid(result$, i%, 1)
Next
RightBack=turn$
End Function

Function Word (sourceString As String, separator As String, number As Integer)
As String
searchString$=SourceString & separator ' add one separator to catch also the
last substring
For i% = 1 To number
pos%=Instr(searchString$, separator)
If pos%=0 Then Exit For
substring$=Left(searchString$,pos%-1)
searchString$=Mid(searchString$, pos%+1)
Next
If pos% > 0 Then
Word=substring$
Else
Word=""
End If
End Function

This was first published in November 2000

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.