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
' NAME=VALUE
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
' of NAME=VALUE
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