Working with Variables

Now let's take a look at the basic syntax rules for working with variables. There are two types of variables that can be utilized in formulastemporary variables and field name variables.

Temporary variables, as the name implies, are used to temporarily store a value associated with the formula. Temporary variables cannot be referenced outside of the formula and only contain a value for the duration of the formula's execution. In other words, the value stored in a temporary variable is not saved when the document or form is saved and cannot be referenced by other formulas.

The syntax for creating a temporary variable is VariableName and the assignment operator := followed by the data value and semicolon. For example, the following assigns "January" to the temporary variable called month.

month := "January";

Conversely, field name variables reference actual fields on a document or form. When used in a formula, you can reference or change the value stored in the field name. In other words, by using formulas, you can use field names to calculate the main expression or modify the value already stored in the field.

There are three ways to reference an existing field. The FIELD keyword is used to assign a value to an existing field. Using this keyword, the contents of the field are permanently changed and will be stored in the field when the document is saved. The syntax for setting a field value in a form or document is FIELD FieldName and the assignment operator := followed by the new value and a semicolon. For example:

FIELD Month := "January";

It's important to note that if the field exists on the form, the new value will replace the existing data value. If the field does not exist on the form, Notes will create the field and assign the value. Alternatively, you can also use the @SetField function. This function works just like FIELD with one exception: @SetField can be imbedded within other Formula Language functions.

@SetField ("Month"; "January");

Finally, to acquire the value of an existing field, you can use the @GetField function. Using this function, you can use the value stored in field inside another formula. For example, the following will create the text string "Your project is due in: January", assuming the Month field contains a value of "January".

"Your project is due in: " + @GetField ( "Month" );

Note

Lotus Notes will recognize a variable name regardless of the letter case. Variable names can be uppercase, lowercase, or mixed case and will still be understood. For example, the following are equivalent variable names: firstname, FIRSTNAME, FirstName, and FIRSTname.



An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management

Security

Application Deployment and Maintenance

Troubleshooting

Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?



Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net