Reading QueryString easier

Function getArgumentValue() can be used in LotusScript Web agents to parse argument values from QueryString. Function recognizes both arguments with an assigned value (like ProdID=123456) and also arguments without a value (like ShowStat).

Rules:
If argument is not present in QueryString, function returns an empty string. If argument with assigned value is present, it returns its value. If argument without assigned value is present, it returns "1".

Code: Function getArgumentValue(queryString As String, argName As String) As String
	Dim delimiter As String, qs As String, pos As Integer
	Dim posVal As Integer, partR As String
	delimiter = "&"
	qs = delimiter + queryString + delimiter
	pos = Instr(1, qs, delimiter + argName + "=", 1)
	If pos > 0 Then
		partR = Right(qs, Len(qs) - (pos + 1 + Len(argName)))
		getArgumentValue = Left(partR, Instr(partR, delimiter)- 1)
	Else
		pos = Instr(1, qs, delimiter + argName + delimiter, 1)
		If pos > 0 Then
			getArgumentValue = "1"
		Else
			getArgumentValue = ""
		End If
	End If
End Function


EXAMPLE: Simple web agent: 

Sub Initialize
	Dim session As New NotesSession
	Dim docContext As NotesDocument
	Dim qs As String
	
	Set docContext = session.DocumentContext
	qs = docContext.Query_String_Decoded(0)
	
	Print "<pre>"
	Print "Product ID: " + getArgumentValue(qs, "ProdID")
	Print "Action: " + getArgumentValue(qs, "Action")
	Print "ShowStat: " + getArgumentValue(qs, "ShowStat")
	Print "Send Notification: " + getArgumentValue(qs, "SendNotif")
	Print "</pre>"
End Sub

Agent called from browser with following URL
http://localhost/tester.nsf/QSReader?openagent⪻odID=123456&Action=Remove&ShowStat

returns these results:

Product ID: 123456
Action: Remove
ShowStat: 1
Send Notification:

This was first published in January 2001

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close