Domino Code Fragment

Code Name*
What are Properties in LotusScript?
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.216.34.146
Description*
Properties in LotusScript? How are they used?
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
Problem:
What are Properties in LotusScript? How are they used?

Solution:
Properties are named pairs of subprograms that can be used as if they were a single variable.
Properties combine the "features" of a variable with the "features" of a subprogram (much the way
Classes in LotusScript do).

Properties are used mostly for syntactical convenience. A script that includes Properties is generally
easier to read than a script without them. In the following examples, Module 1 contains a SUB and
a FUNCTION. Module 2 implements the same SUB and FUNCTION using Properties:

First Module:

SUB SetSubDir (todir AS STRING)
'Defines the SUB name and gives it one argument
CHDIR "C:\WORK" + todir
'Uses the CHDIR statement to set the current directory to "C:\WORK" +
'whatever the variable TODIR holds.
END SUB

FUNCTION GetSubDir 'Defines the FUNCTION name
GetSubDir=MID$ (CURDIR$,9,255)
END FUNCTION
'This FUNCTION statement sets the variable GetSubDir equal to the
'results of the MID$ function, which extracts a string from within
'another string using a beginning character specified. In this case,
'the beginning character is in position 9, and the total length is set
'to 255. This string is extracted from the result of the CURDIR
'function which returns a string containing the path of the current
'directory. The net result is the "C:\WORK" gets "chopped off",
'leaving just the subdirectory.

The SUB SetSubDir and the FUNCTION GetSubDir can be used together to work in any
subdirectory of "C:\WORK" as follows:

X$=GetSubDir ( )
'assigns to the string variable X the result of the FUNCTION
'GetSubDir, which would return the current subdirectory which, in
'this case, is "C:\WORK."
SetSubDir "123"
'Calls the SUB SetSubDir, giving the string argument "123." This
'sets the current subdirectory to "C:\WORK\123"
SetSubDir X$
'Calls the SUB SetSubDir again, using the string variable X as
'the argument, and X is currently eqaul to "C:\WORK." Thus, the 'current subdirectory is set back
to "C:\WORK."

----------------------------------------------------------------------

Second Module:

PROPERTY SET SubDir AS STRING
CHDIR "C:\WORK" + SubDir
'Append the contents of the variable SubDir to the current directory.
END PROPERTY

PROPERTY GET SubDir AS STRING
SubDir = MID$ (CURDIR$,9,255)
'As in the Module 1, cuts of the "C:\WORK" from the current
'directory and returns the rest of the path.
END PROPERTY

To use the above property, use the following script:

X$= SubDir
'Stores the current directory in the string variable X. This calls
'the PROPERTY GET SubDir. This is the equivalent of calling the
'FUNCTION GetSubDir in Module 1.
SubDir = "123"
'Calls the PROPERTY SET SubDir which sets the current subdirectory
'to "C:\WORK\123". This is the equivalent of calling the SUB
'SetSubDir in the First Module.
SubDir = X$
'Calls the PROPERTY SET SubDir again, only this time, it sets the
'current subdirectory to the contents of the string variable X,
'which was "C:\WORK."

As a rule, when the name of a Property is on the left side of an assignment or SET statement, the
PROPERTY SET subprogram is called. When the name of the Property is on the right side of an
assignment statement, the PROPERTY GET subprogram is called. You can think of it in terms of
"Right = Get, Left = Set."

Supporting Information:

Related Documents:

What is an Array in LotusScript?
Document #: 126419

What is the Difference Between Type and Class in LotusScript?
Document #: 126415

Lotus Forms Classes in LotusScipt
Document #: 124995