|
|
|
|
|
|
|
|
|
|
|
|
|
|
LotusScript's Evaluate command (continued)
The function returns the Variant value created by the call to the @Adjust function. Here's how it may be used. The following code is contained in a button on an open document. A date value is retrieved from a field on the document, and numerous documents are created (for three successive dates).
1.Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dateText As String
Dim temp As Variant
Dim x As Long
2.Set uidoc = ws.CurrentDocument
3.Set db = uidoc.Document.ParentDatabase
4.dateText = ui.FieldGetText ( "StartDate" )
5.temp = DateValue( dateText )
6.For x = 1 to 3
7.Set doc = db.CreateDocument
8.doc.Form = "Test"
9.newDate = AdjustDate(0, 0, x, temp)
10.doc.StartDate = newDate(0)
11.Call doc.Save(True,False)
Next x
|
The explanation for each of the numbered lines is as follows:
- The current environment is accessed.
- The currently open document is accessed.
- The NotesDatabase object is instantiated; it is necessary to create new documents.
- The date value is retreived from open document. This is the starting date for creating new documents.
- The text date value is changed to a date value.
- A for loop is used to create three new documents.
- A new document is created.
- The form field is set.
- The AdjustDate function is used to increment the date value with the loop index value.
- The StartDate value on the field is populated using the function return value.
- The new document is saved.
The previous code is application specific, but it does showcase the use of Evaluate. The next example is simpler; it uses the @Name function.
Dim userName As Variant
username = Evaluate( |@Name([CN];@UserName)|)
MsgBox "Your common name is: " & username(0),0,"Username"
|
Usage rules What are the rules to keep in mind when you're working with the LotusScript Evaluate function?
When you're working with the Evaluate function, keep the following points in mind.
The first parameter is a string value. Ensure that you use the proper syntax, particularly in cases where the @Function referenced within the Evaluate function contains parameters within quotation marks.
Here are a couple examples:
When passing the parameter enclosed in quotations marks, the parameters of the @function must be included in a pair of quotation marks:
Result = Evaluate( "@ReplaceSubstring(SourceField; ""errr"";""error"")", doc)
|
When passing the parameter enclosed in vertical bars, the parameters of the @function must be enclosed in a single set of quotation marks:
Result = Evaluate(|@ReplaceSubstring(SourceField; "errr";"error")|, doc)
|
The parameters within the referenced @function must be either a field name, within the document, or text. Extended syntax is not allowed. Also, in Notes releases 4.1x and 4.5x, you are not allowed to use a LotusScript variable to set a parameter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Learn Notes and Domino 8 at your place and pace!
Learn Notes and Domino in your office and/or home! TLCC's highly acclaimed distance learning courses for users, developers, and admins will enhance your career and your resume.
The many included activities and demos will make you a pro! Expert instructor help is a click away.
Click here to try a FREE demo course!! |
-- Advertisement --
Teamstudio Edition 25 has shipped
It's finally here! Now that Teamstudio Edition 25 has shipped, listen to our latest Tool Time audio program to find out what's changed. Updates to all your favorite Teamstudio tools will be discussed.
Plus, you'll get an introduction to Teamstudio Undo (formerly known as Teamstudio Snapper).
Tap here to get started! |
|
|
|
|
|
|
|
|
|
|