Defining Variables and Constants

With the terminology and object-oriented programming concepts out of the way, we are ready to discuss the general syntax and structure of the LotusScript language starting with variables. There are essentially two steps required to utilize a variabledeclare and set. The DIM statement is used to declare variables in LotusScript. The syntax for declaring a variable is

DIM variablename AS declarationType

After the variable has been declared, you can the set the variable to a literal string, built-in data value, or object. For example, the following shows several variables being declared.

'--- Declare Regular Variables
Dim TotalHolidays As Integer
Dim ThisMonth As String
Dim AuthorName As String

'--- Declare Object Reference Variables
Dim theDate As New NotesDateTime

'--- Set the variables
TotalHolidays = 5
ThisMonth = "January"
theDate.LSLocalTime = Now

The following represents some of the built-in values that can be assigned to variables.




A special value that indicates "missing" or "unknown" data. It's important to understand that a NULL value does equate to an actual value.


Indicates that the variable does not contain a value.


Sets the variable to the value of pi (which is the ratio between a circle's circumference and its diameter).


Sets the value of the variable to 1.


Sets the value of the variable to 0.


The current date and time.


The current date.

Alternatively, you can declare regular variables by using the associated symbol. Using this method, the variable is automatically declared and set to the specified variable type. However, best practices suggest that you should always declare the variable.

CurrentDirectory$ = "C:"
TotalHolidays% = 5

Constants hold a static value and are typically defined in LotusScript libraries. Constants can be defined throughout the application including in forms and subroutines. The syntax for declaring a constant is as follows.

[ Public | Private ] Const ConstName = expression

Public Indicates that the constant can be used outside the current module. This is an optional parameter.

Private Indicates that the constant is only visible within the current module. This is the default setting and is an optional parameter.

ConstName The name of the constant to be referenced throughout the LotusScript code. This value must be uniqueit cannot be the same name as another variable or constant.

expression The value to be assigned to the constant.

For example, the following illustrates several constants. As a best practice, consider using all caps or a unique prefix identifier such as "const" to denote a constant variable.

'--- Declare Constants
Const MonthsInYear = 12
Const DaysInWeek = 7
Public Const PiValue = PI

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


Application Deployment and Maintenance


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 © 2008-2020.
If you may any questions please contact us: