Domino Code Fragment

Code Name*
Get paramter value from query string
Date*
02/03/1999
Source (or email address if you prefer)*
Niels Ull Harremoes
IP address:.18.117.216.36
Description*
Type*
LotusScript
Categories*
User Interface (Web)
Implementation:
None (plug and play)
Required Client:
(none)
Server:
4.6
Limitations:
There is no way to distinguish an empty parameter from a missing parameter.

URLEncoding/decoding is not handled
Comments:
If you retrieve many values from the query string, this is a bit inefficinet, since it is retrieving the session, the document context and the querystring several times.
Files/Graphics attachments (if applicable): Code:
Function getParamFromQueryString(Param As String) As String
'Input : The name of a query-string parameter
'Output: The value, if any, defined for the parameter in the current query string
'Limitations:
' There is no way to distinguish an empty parameter from a missing parameter (see Age in the example below)
' URLEncoding/decoding is not handled (see Name in the example below)
'Example:
' Assume the url is http://server/mydb.nsf/MyAgent?OpenAgent&Name=Joe+Smith&Age=&Sex=Male
' getParamFromQueryString("Name") = "John+Doe"
' getParamFromQueryString("Sex") = "Male"
' getParamFromQueryString("Age") = ""
' getParamFromQueryString("SSN") = ""
'
Dim ses As New NotesSession

Dim contextDoc As NotesDocument
Set contextDoc = ses.DocumentContext
Dim value As String

value = contextDoc.query_String(0)
Print "Query string : " + Value + " "
Msgbox "Query string : " + Value + " "
Dim index As Integer
index=Instr(value, "&" + param + "=")
If (index=0) Then
value=""
Else
value= Mid$(value, index+Len(param)+2)
index = Instr(value, "&")
If (index > 0) Then
value=Left$(value, index)
End If

End If
getParamFromQueryString = value
End Function