Domino Code Fragment

Code Name*
Adding a Variable into String for LotusScript Search Method
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.220.66.151
Description*
Adding a Variable into String for LotusScript Search Method
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Problem:
What is the correct syntax for adding a string variable into the search string argument of

the LotusScript Search Method?

Solution:
Below are two examples which illustrate correct syntax. The first example uses the vertical

bar character to create the string, and the second example uses quotation marks. Note that
when quotation marks are embedded within the actual string, the use of the vertical bar may
be preferable.

Example 1: Vertical Bar

Dim nab As New NotesDatabase( "" ,"Names.Nsf" )
Dim collection As NotesDocumentCollection
Dim selection As String
Dim x As String
y = "Group"
selection = |ListName="LocalDomainServers" & Form="| & y & |"|
Set collection = nab.search(selection, Nothing, 0)


Example 2: Quotation Marks

Dim nab As New NotesDatabase("","Names.Nsf")
Dim collection As NotesDocumentCollection
Dim selection As String
Dim y As String
y = "Group"
'Note: In the next line of script, there are 2 quotes following ListName=" ",
'2 quotes following LocalDomainServers " ", 3 quotes following Form=" " ",
'and 4 quotes following the final ampersand & " " " ".
selection = "ListName= ""LocalDomainServers"" & Form=""" & y & """"
Set collection = nab.search(selection, Nothing, 0)