Home > Working with variables in Formula language for Lotus Notes
Tutorial:
EMAIL THIS

Working with variables in Formula language for Lotus Notes

06 Mar 2007 | SearchDomino.com

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   

The following is tip #2 from "A Formula language for Lotus Notes introduction -- 7 tips in 7 minutes," excerpted from Chapter 5 of the book Lotus Notes Developer's Toolbox, published by IBM Publishing.

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 formulas -- temporary 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 a 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.


A Formula language for Lotus Notes introduction

 Home: Introduction
 Tip 1: What is Lotus Formula Language?
 Tip 2: Working with variables in Formula language for Lotus Notes
 Tip 3: Lotus Notes Formula language keywords
 Tip 4: Working with operators in Formula language for Lotus Notes
 Tip 5: Lotus Notes Formula language general syntax rules
 Tip 6: What are Lotus Notes Formula language functions and commands?
 Tip 7: Working with text strings in Formula language for Lotus Notes

An Introduction to Formula Language This chapter excerpt from Lotus Notes Developer's Toolbox, by Mark , is printed with permission from IBM Publishing, Copyright 2006.

Click here for the chapter download or purchase the book here.



Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary




Lotus Notes Administration Solutions for Performance, Monitoring, Mailbox Management and Synchronization
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts