Class QSParser
'Private member vars
session As NotesSession
doc As NotesDocument
strQS As String
vntQS As Variant
intCount As Integer
arrQSName() As String
arrQSValue() As String
' ---------------------------------------------------------------------
Sub New
'Instantiate our objects, retrieve the querystring from the
'context doc and call the parsing routine.
Set session = New NotesSession
Set doc = session.DocumentContext
strQS = doc.QUERY_STRING_DECODED(0)
Call Me.ParseQS
End Sub
' ---------------------------------------------------------------------
Private Sub ParseQS
'Split the querystring into an array
vntQS = Split(strQS,"&")
'Loop throught the array and create name / value arrays. I am
'starting the loop at one and not zero so that we ignore the 'openagent'
'parameter in the querystring.
For intCount = 1 To Ubound(vntQS)
Redim Preserve arrQSName(intCount - 1)
Redim Preserve arrQSValue(intCount - 1)
'Store the name / value pair in seperate arrays using strtoken
arrQSName(intCount - 1) = Strtoken(vntQS(intCount),"=",1)
arrQSValue(intCount - 1) = Strtoken(vntQS(intCount),"=", 2)
Next
End Sub
' ---------------------------------------------------------------------
Public Function GetQSVal (strQSName As String) As String
'Given the Query String name, return it's associated value
'by finding its index in the arrQSName array.
Dim vntIndex As Variant
vntIndex = Arraygetindex(arrQSName, strQSName, 5)
If Not(Isnull(vntIndex)) Then
GetQSVal = arrQSValue(vntIndex)
End If
End Function
' ---------------------------------------------------------------------
End Class
Usage
Dim objQS As New QSParser
Dim key As String
key = objQS.GetQSVal("key")
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment