Function urlDecode(s As String) As String
If Len(s) = 0 Then Exit Function
Dim i As Integer
Dim tmp As String
Dim c As String
For i = 1 To Len(s)
c = Mid$(s, i, 1)
If c = "+" Then c = " "
If c = "%" Then
c = Chr$("&H" + Mid$(s, i + 1, 2))
i = i + 2
End If
tmp = tmp + c
Next i
urlDecode = tmp
End Function
Monday, November 17, 2008
LotusScript equivalents for the @URLEncode
Function urlEncode(s As String) As String
If Len(s) = 0 Then Exit Function
Dim tmp As String
Dim c As String
Dim i As Integer
For i = 1 To Len(s)
c = Mid(s, i, 1)
If (Asc(c) >= 65 And Asc(c) <= 90) _
Or (Asc(c) >= 97 And Asc(c) <= 122) _
Or (Asc(c) >= 48 And Asc(c) <= 58) _
Or Asc(c) = 38 _
Or (Asc(c) >= 45 And Asc(c) <= 47) _
Or Asc(c) = 58 Or Asc(c) = 61 _
Or Asc(c) = 63 Or Asc(c) = 126 Then
tmp = tmp + c
Else
tmp = tmp + "%" + Hex(Asc(c))
End If
Next i
urlEncode = tmp
End Function
If Len(s) = 0 Then Exit Function
Dim tmp As String
Dim c As String
Dim i As Integer
For i = 1 To Len(s)
c = Mid(s, i, 1)
If (Asc(c) >= 65 And Asc(c) <= 90) _
Or (Asc(c) >= 97 And Asc(c) <= 122) _
Or (Asc(c) >= 48 And Asc(c) <= 58) _
Or Asc(c) = 38 _
Or (Asc(c) >= 45 And Asc(c) <= 47) _
Or Asc(c) = 58 Or Asc(c) = 61 _
Or Asc(c) = 63 Or Asc(c) = 126 Then
tmp = tmp + c
Else
tmp = tmp + "%" + Hex(Asc(c))
End If
Next i
urlEncode = tmp
End Function
Saturday, November 15, 2008
LotusScript equivalents for the @ProperCase
Function properCase(Byval txtIn As String) As String
properCase = Strconv(txtIn, 3)
End Function
properCase = Strconv(txtIn, 3)
End Function
LotusScript equivalents for the @ReplaceSubstring
Function ReplaceSubstringEvaluate (Byval fullString As String, oldString As String,
newString As String) As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim var As Variant
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("FullString", fullString)
Call doc.ReplaceItemValue("OldString", oldString)
Call doc.ReplaceItemValue("NewString", newString)
var = Evaluate("@ReplaceSubstring(fullString; oldString; newString)", doc)
ReplaceSubstringEvaluate = var(0)
'** clean up the memory we used
Set doc = Nothing
Set db = Nothing
End Function
newString As String) As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim var As Variant
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("FullString", fullString)
Call doc.ReplaceItemValue("OldString", oldString)
Call doc.ReplaceItemValue("NewString", newString)
var = Evaluate("@ReplaceSubstring(fullString; oldString; newString)", doc)
ReplaceSubstringEvaluate = var(0)
'** clean up the memory we used
Set doc = Nothing
Set db = Nothing
End Function
Wednesday, November 12, 2008
LotusScript equivalents for the @Elements
Function Elements(anArray as Variant) as Integer
i = 0
Forall values in anArray
i = i + 1
End Forall
Elements = i
End Function
i = 0
Forall values in anArray
i = i + 1
End Forall
Elements = i
End Function
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
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
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
' 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
'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
'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
'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
'Script equivalent to @Begins
If Instr ( fullString, subString) = 1 Then
Begins = True
Else
'Begins is False
End If
End Function
Sunday, November 2, 2008
LotusScript equivalents for the @Left
Function LeftOf (sourceString As String, searchString As String) As String
'LotusScript equivalents for the @Left
pos% = Instr(sourceString, searchString)
If pos% > 0 Then pos% = pos% -1
LeftOf = Left(sourceString, pos%)
End Function
'LotusScript equivalents for the @Left
pos% = Instr(sourceString, searchString)
If pos% > 0 Then pos% = pos% -1
LeftOf = Left(sourceString, pos%)
End Function
LotusScript equivalents for the @Right
Function RightOf (sourceString As String, searchString As String) As String
'LotusScript equivalents for the @Right
pos% = Instr(sourceString, searchString)
length% = Len(sourceString)
start% = length% - pos%
RightOf = Right(sourceString, start%)
End Function
'LotusScript equivalents for the @Right
pos% = Instr(sourceString, searchString)
length% = Len(sourceString)
start% = length% - pos%
RightOf = Right(sourceString, start%)
End Function
Subscribe to:
Posts (Atom)