The array functions in LotusScript.

Source: Internet
Author: User

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.

[VB]View Plaincopy
  1. %REM
  2. Checks If an array contains a value.
  3. The Arraygetindex function returns null if the value is not found.
  4. %end REM
  5. Public Function arraycontains (source As Variant, value as variant) as Boolean
  6. ' The data type of source is not checked intentionally
  7. Arraycontains= notIsNull (Arraygetindex (source,value))
  8. 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.

[VB]View Plaincopy
  1. ' Returns the number of an array ' s dimensions
  2. Function arraydimension (array as Variant) as Integer
  3. If not IsArray (array) Then
  4. Arraydimension=0
  5. Exit Function
  6. End If
  7. on Error errsubscriptoutofrange GoTo RESULT
  8. Dim D As Integer, lb as integer
  9. For d=1 to 9
  10. Lb=lbound (Array, D)
  11. Next
  12. RESULT:
  13. Arraydimension=d-1
  14. Exit Function
  15. End Function

Returns the size of a multidimensional array, that is, the number of all elements.

[VB]View Plaincopy
  1. Function ArraySize (array as Variant) as Integer
  2. If not IsArray (array) Then
  3. Arraysize=0
  4. Exit Function
  5. End If
  6. Arraysize=1
  7. Dim D as Integer
  8. D=arraydimension (Array)
  9. Dim i as Integer
  10. For I=1 to D
  11. arraysize=arraysize* (UBound (array, i)-lbound (array,i) +1)
  12. Next
  13. End 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.

[VB]View Plaincopy
  1. Function arrayboundsequals (A1 as Variant, A2 as variant) as Boolean
  2. If (notIsArray (A1)) Or (notIsArray (A2) ) Then
  3. arrayboundsequals=False
  4. Exit Function
  5. End If
  6. Dim d1 As Integer, D2 as integer
  7. D1=arraydimension (A1)
  8. D2=arraydimension (A2)
  9. If d1<>d2 Then
  10. arrayboundsequals=False
  11. Exit Function
  12. End If
  13. Dim D as Integer
  14. For d=1 to D1
  15. If LBound (A1) ><lbound (A2) Or UBound (A1) ><ubound (A2) Then
  16. arrayboundsequals=False
  17. Exit Function
  18. End If
  19. Next
  20. arrayboundsequals=True
  21. End Function

Converts a multidimensional array into a one-dimensional array. This function is also used to compare the equality of two arrays.

[VB]View Plaincopy
  1. Function arraytoonedimension (array as variant) as variant
  2. If not IsArray (array) Then
  3. Call SetValue (arraytoonedimension, array)
  4. Exit Function
  5. End If
  6. Dim D as Integer
  7. D=arraydimension (Array)
  8. If d=1 Then
  9. Arraytoonedimension=array
  10. Exit Function
  11. End If
  12. Dim size as Integer
  13. Size=arraysize (Array)
  14. Dim result () as Variant
  15. ReDim result (size-1)
  16. Dim i as Integer
  17. ForAll e in array
  18. Result (i) =e
  19. I=i+1
  20. End ForAll
  21. Arraytoonedimension=result
  22. End Function

The array functions in LotusScript.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.