Search DominoPower's 11,429 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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:

  1. The current environment is accessed.

  2. The currently open document is accessed.

  3. The NotesDatabase object is instantiated; it is necessary to create new documents.

  4. The date value is retreived from open document. This is the starting date for creating new documents.

  5. The text date value is changed to a date value.

  6. A for loop is used to create three new documents.

  7. A new document is created.

  8. The form field is set.

  9. The AdjustDate function is used to increment the date value with the loop index value.

  10. The StartDate value on the field is populated using the function return value.

  11. 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.


« Previous  ·  1  ·  2  ·  3  ·  Next »
Other articles you might like
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
IBM Lotus to Google Apps Migration Remorse
Webcast Series: Mobile Collaboration with Lotus Software
Domino Login Control for Mobile Apps
Sys Admin Tips March 2010
Quickr place Superusers
Writing Client-Side Javascript for Re-Use
Lotus Notes R8.5.1: Bug in Contacts "Print Selected View"
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- 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!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login