Domino Code Fragment

Code Name*
Equivalent Rightback and Leftback functions in LotusScript
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.119.132.223
Description*
Equivalent Rightback and Leftback functions in LotusScript
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Code for Leftback and Rightback in LotusScript.

Function LeftBack (Byval Text As String, Delim As String) As
String
'This function returns the part of the string to the left 'of the delimiting character, which is searched for
from 'the right (back) of the string. If the delimiter isn't 'found, the entire string is returned.
Dim length As Integer
Dim pos As Integer
Dim character As String
length = Len ( Text )
pos = length
character = Mid$ ( text, length, 1 )
'Search the string character-by-character, until either the 'delimiter is found or the beginning of the string is
reached.


While ( Not character = Delim ) And ( pos > 1 )
pos = pos - 1
character = Mid$ ( Text, pos, 1 )
Wend


'If the position pointer is greater than 1, the delimiter 'was found and part of the string is returned.
'Else, if the first character matches the delimiter, there 'aren't any characters to the left of the delimiter and
an 'empty string is returned.
'Else the delimiter wasn't found and the string is returned.


If pos > 1 Then
LeftBack = Left$ ( Text, pos - 1 )
Else
If character = Delim Then
LeftBack = ""
Else
LeftBack = Text
End If


End If

End Function

Function RightBack ( Byval Text As String, Delim As String )
As String
'This function returns the part of the string to the right 'of the delimiting character, which is searched for
from 'the right (back) of the string.
'If the delimiter is not found, the string is returned.
Dim length As Integer
Dim pos As Integer
Dim character As String
length = Len ( Text )
pos = length
character = Mid$ ( text, Length, 1 )


'Search the string character-by-character until a delimiter 'isn't found, or until the beginning of the string is
'reached.


While ( Not character = Delim ) And ( pos > 1 )
pos = pos - 1
character = Mid$ ( Text, pos, 1 )
Wend


'If the position pointer is greater than 1, the delimiter 'was found and part of the string is returned.
'Else, if the first character matches the delimiter, return 'all but the first character as the result string.
'Else a delimiter wasn't found and the entire string is 'returned.


If pos > 1 Then
RightBack = Right$ ( Text, length - pos )
Else
If character = Delim Then
RightBack = Right$ ( Text, length - 1 )
Else
RightBack = Text
End If
End If


End Function

Function LeftChar ( Byval Text As String, Delim As String ) As String

'This function returns the part of the string left from the 'delimiting character, which is searched for from
the left 'of the string. If a delimiter isn't found, the entire 'string is returned.


Dim length As Integer
Dim pos As Integer
Dim character As String
length = Len ( Text )
pos = 1
character = Mid$ ( Text, pos, 1 )


'Search the string character by character until the
'delimiter is found, or until the end of the string is 'reached


While ( Not character = Delim ) And ( pos <= length )
pos = pos + 1
character = Mid$( Text, pos, 1 )
Wend


'If the pointer is beyond the length of the string, a 'delimiter wasn't found and the entire string is returned.
'Else the delimiter was found and the part of the string 'left of the pointer is returned.


If pos > length Then
LeftChar = Text
Else
LeftChar = Left$ ( Text, pos - 1)
End If
End Function


Function RightChar ( Byval Text As String, Delim As String ) As String
'This function returns the part of the string right from 'the delimiting character which is searched for from
the 'left of the string.
'If the delimiter is not found, the entire string is 'returned.


length = Len ( Text )
pos = 1
character = Mid$ ( Text, pos, 1 )


'Search the string character-by-character until the
'delimiter is found, or until the end of the string is 'reached.


While ( Not character = Delim ) And ( pos <= length )
pos = pos + 1
character = Mid$( Text, pos, 1 )
Wend


'If the pointer is beyond the length of the string, a 'delimiter wasn't found and the entire string is returned.
'Else the delimiter was found and the part of the string 'right of the pointer is returned.


If pos > length Then
RightChar = Text
Else
RightChar = Right$ ( Text, length - pos)
End If


End Function