R6 has some improvements and enhancements to LotusScript, and since then, the interface of the Notes object has been supplemented and updated, but the language itself has not changed. Those improvements include the addition of useful functions such as arraygetindex and Arrayunique. In programming practice, however, there are some operations lotusscript that do not provide native functions, but can basically be written by themselves. The constants used in the following functions are defined in LSCONST.LSS or LSERR.LSS, and are appended before the script
%INCLUDE "LSCONST.LSS"
%INCLUDE "LSERR.LSS"
Determines whether an array contains an element.
%remchecks If an array contains a value. The Arraygetindex function returns null if the value is not found.%end rempublic function arraycontains (source as Variant, Value as Variant) as Boolean ' the data type of source is not checked Intentionallyarraycontains=not IsNull (Arraygetindex (s Ource,value)) End Function
The array in LotusScript can have up to eight dimensions (dimension), and the following function takes advantage of a run-time error (run-time error) Errsubscriptoutofrange to obtain the dimension.
' Returns the number of an array ' s dimensionsfunction arraydimension (array as Variant) as Integerif not IsArray (array) Then Arraydimension=0exit Function End ifon Error errsubscriptoutofrange GoTo resultdim D As Integer, lb as Integer for d=1 To 9lb=lbound (array, D) Nextresult:arraydimension=d-1exit function End function
Returns the size of a multidimensional array, that is, the number of all elements.
function ArraySize (array as Variant) as Integerif not IsArray (array) thenarraysize=0exit Function End Ifarraysize=1dim D A s integerd=arraydimension (array) Dim I as Integerfor i=1 to darraysize=arraysize* (UBound (array, i)-lbound (array,i) +1) NextEnd Function
Determine the "shape" of two arrays, i.e. whether the dimensions are the same as the upper and lower bounds of each dimension. This function is useful when comparing arrays for equality in the future.
Function Arrayboundsequals (A1 as Variant, A2 as Variant) as booleanif (not IsArray (A1)) Or (not IsArray (A2)) Thenarrayboun Dsequals=falseexit Function End Ifdim d1 as Integer, D2 as Integerd1=arraydimension (A1) d2=arraydimension (A2) If d1< >d2 Thenarrayboundsequals=falseexit functionend Ifdim D as integerfor d=1 to D1if LBound (A1) ><lbound (A2) Or UBoun D (A1) ><ubound (A2) thenarrayboundsequals=falseexit functionend ifnextarrayboundsequals=true End Function
Converts a multidimensional array into a one-dimensional array. This function is also used to compare the equality of two arrays.
Function arraytoonedimension (array as Variant) as Variantif not IsArray (array) Thencall SetValue (Arraytoonedimension, Array) Exit Function End Ifdim D as integerd=arraydimension (array) If d=1 thenarraytoonedimension=arrayexit functionend Ifdim size as Integersize=arraysize (array) Dim result () as Variantredim result (size-1) Dim i As Integer ForAll e in Arrayres Ult (i) =ei=i+1end forallarraytoonedimension=resultend Function
The array functions in LotusScript.