Hi guys
I am supporting a Lotusscript agent that I cannot save/alter as one of the functions errors with the error Unexpected: Replace; Expected: Identifier: BYVAL.
My question, is the function name used here a RESERVED Lotusscript function, or is there something wrong with the syntax of the code that I cannot see?
FUNCTION code:
Function SubString (string1 As String, match As String, replace As String) As String
' finds a matching string within a string and replaces it with the replace string
Dim mlen As Integer
Dim slen As Integer
Dim pos As Integer
Dim startpos As Integer
Dim firstpart As String
Dim lastpart As String
Dim result As String
' get the length of the match string
mlen = Len(Match)
' get the length of the string
slen = Len(String1)
' find the position of the match within the sting
pos = Instr(string1, match)
If pos = 0 Then
Substring = string1
Exit Function
End If
startpos = 1
' get the first part of the string
firstpart$ = Mid$(string1$, startpos, pos - 1)
' get the last part of the string
lastpart$ = Right$( string1$, slen - mlen - pos + 1)
' stick the two parts back together without the match and with the replace string
result = firstpart + replace + lastpart
SubString = Substring(result, match, replace)
End Function