Date tip published: | 11/09/99 |
Description: | Create a text string in LotusScript. |
To learn more about LotusScript use the following links:
R5 Beginner LotusScript for Notes and Domino
R5 LotusScript Package
The first thing you probably did when learning LotusScript was create a text string. To do this, you probably wrote some code like the following:
Dim x as string
x = "Hello World"
MessageBox x
The above example uses quotes to delimit or build the text string. Using a quote as a text string delimiter works great most of the time. But what if you need to include quotes in your text string? You can precede each quote within the string with a quote, but the resulting expression can get very ugly. An alternative is to enclose the complete string expression, including quotes, within another string delimiting pair, like vertical bars or open and close braces.
Consider the example of providing a formula criteria for the Search method of the NotesDatabase class. The Search method takes a parameter which is the formula needed to Search a database and return documents which meet the specified criteria. Assume we have an Orders database where each order is created with the Order form and the OrderRegion field indicates the region. To get a collection of orders for the "East" region, you would use the following search formula:
Form = "Order" & OrderRegion = "East"
Notice there are quotes needed around "Order" and "Region" in this search formula. To represent this formula as a string using quotes, you need to precede each quote within the string with a quote. The following statements, although syntactically correct, are difficult to debug and maintain:
Dim sSearchCriteria As String
sSearchCriteria = "Form = ""Order"" & OrderRegion = ""East"""
Instead of using quotes to delimit the string, use a vertical bar ( | ). Now your code looks like the following:
Dim sSearchCriteria As String
sSearchCriteria = | Form = "Order" & OrderRegion = "East" |
This is much easier to read and debug. You can use any of the following characters to delimit a text string:
- A pair of double quotation marks ( " " )
- A pair of vertical bars ( | | )
- A pair of open and close braces ( { } )
|