Parsing URL Parameters Simply

One of my projects required sending of some parameters to documents or agents via URL. I didn't want to write some long code and even I wanted to reuse it in script and with minor changes in formulas, if possible.

Code for LS:

Dim Session As NotesSession
Dim Doc As NotesDocument

Dim Prms, Nms, Vls

Sub ParseQueryParams(S, Params)
' Function simply parses 
' string delimited by '&' into
' vector of values in form

Params = Evaluate("@Explode(@Right(""" & S & """; ""&""); ""&"")")
End Sub

Sub ParseQueryParams_NameValue(S, Names, Values)
' Function simply parses 
' string delimited by '&' into
' 2 vectors of names
' and values

Names = Evaluate("@Word(@Explode(@Right(""" & S & """; ""&""); ""&""); ""=""; 1)")
Values = Evaluate("@Word(@Explode(@Right(""" & S & """; ""&""); ""&""); ""=""; 2)")
End Sub

Sub Initialize
Set Session = New NotesSession

' Following row will get Document
' which is passed to agent
Set Doc = Session.DocumentContext
' Following row processes
' Query_String_Decoded CGI variable
' passed to agent
' and returns vector 
Call ParseQueryParams(Doc.Query_String_Decoded(0), Prms) 

' Following row processes
' Query_String_Decoded CGI variable
' passed to agent
' and returns 2 vectors 
' with names and values
Call ParseQueryParams_NameValue(Doc.Query_String_Decoded(0), Nms, Vls) 

End Sub

When it's required to parse parameters in document, it's possible to parse parameters accordingly in formulas (note that Query_String_Decoded field of text type, even computed for display, MUST exist in form:

Parameters := @Explode(@Right(Query_String_Decoded; "&"); "&"); ParamNames := @Word(Parameters; "="; 1); ParamValues := @Word(Parameters; "="; 2);

This was first published in February 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.