Wednesday, November 12, 2008

LotusScript equivalents for the @Replace

Function StringStuffReplaceString(strArg As String, strSrc As String,strDst As String) As String
Dim iPos As Integer
iPos = Instr(strArg, strSrc)
While iPos > 0
strArg = Left$(strArg, iPos - 1) + strDst + Mid$(strArg, iPos + Len(strSrc))
iPos = Instr(iPos + Len(strDst), strArg, strSrc)
Wend
StringStuffReplaceString = strArg
End Function

LotusScript equivalents for the @Picklist

Sub Click(Source As Button)
Dim ws as new notesuiworkspace
dim mailfile as string
dim mailserver as string
dim varFolder as variant


mailfile=ses.GetEnvironmentString( "MailFile", True) mailserver=ses.GetEnvironmentString( "MailServer", True)
varFolder=ws.PickListStrings( 4, False, mailserver, mailfile)

'False to select a single folder or specify True to select multiple folders by holding the Crtl-key

if isEmpty(varFolder) then exit sub

End Sub

Wednesday, November 5, 2008

LotusScript equivalents for the @Dbcolumn

Function Dbcolumn(s As NotesSession, servernm As String, dbname As String, vname As String, colno As Integer) As Variant
' this function retrieves a view's column values from the database (db) in a specified view
' this function returns the resulting values of the lookup as an array.

Dim Db As NotesDatabase ' lookup database
Dim lupV As NotesView ' lookup view
Dim eCol As NotesViewEntryCollection ' all entries in view
Dim e As NotesViewEntry ' entry of eCol
Dim tmpcount As Long ' counting variable for tmpArray
Dim tmpArray() As Variant ' values of lupItem in lupdoc(s)
Dim LSDbCol As Variant

On Error Goto LUpErrorHandler

' get database
Set Db=s.GetDatabase(servernm, dbname, False)
If (Db Is Nothing) Then
' return nothing
LSDbCol=""
Exit Function
End If
Set lupV=Db.GetView(vname)
If (lupV Is Nothing) Then
' return nothing
LSDbCol=""
Exit Function
End If

Set eCol=lupV.AllEntries
Set e = eCol.GetFirstEntry()
If (e Is Nothing) Then
' no entries in view, return nothing
LSDbCol=""
Exit Function
End If

' have entries, loop and add to new list
tmpcount=0
While Not (e Is Nothing)
' redim array
Redim Preserve tmpArray(tmpcount)
' get column value
tmpArray(tmpcount) = Cstr(e.ColumnValues(colno))
tmpcount=tmpcount + 1
Set e = eCol.GetNextEntry(e)
Wend

' return result
LSDbCol=tmpArray
Exit Function

LUpErrorHandler:
' print error to console
Print "(LSDbCol) Unexpected error: " & Error$ & " (" & Cstr(Err) & "), on line: " & Cstr(Erl)
' return nothing
LSDbCol=""
Exit Function

End Function

Tuesday, November 4, 2008

LotusScript equivalents for the @Leftback

Public Function LeftBack(stringToSearch As String, param2 As Variant)
'This is an exact version of @LeftBack() in LotusScript
Const V_INTEGER = 2
Const V_STRING = 8
Const ErrTypeMismatch = 13

Dim v As Variant

If Datatype(param2) = V_INTEGER Then
Let v = Evaluate(|@LeftBack("| & stringToSearch & |"; | & param2 & |)|)
Elseif Datatype(param2) = V_STRING Then
Let v = Evaluate(|@LeftBack("| & stringToSearch & |"; "| & param2 & |")|)
Else
Error(ErrTypeMismatch)
End If

Let leftBack = v(0)

End Function

LotusScript equivalents for the @RightBack

Function RightBack (sourceString As String, searchString As String) As String
'LotusScript equivalents for the @RightBack
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

Monday, November 3, 2008

LotusScript equivalents for the @Ends

Function Ends (fullString As String, subString As String)
'Script equivalent to @Ends
If Instr ( Right$ (fullString, Len(subString)), subString) = 1 Then
Ends = True
Else
Ends = False
End If
End Function

LotusScript equivalents for the @Begins

Function Begins (fullString As String, subString As String)
'Script equivalent to @Begins
If Instr ( fullString, subString) = 1 Then
Begins = True
Else
'Begins is False
End If
End Function