• Browse Blogs
  • My Blog
  • My Updates

+Tags Get help with tags?

  • View as cloud  | list

+ Similar Blogs

photo

Yellow is the...

72 Entries |  Tim Tripcony
Updated 
RatingsRatings 2     CommentsComments 34
photo

Lotus Nut

111 Entries |  Chris Whisonant
Updated 
RatingsRatings 23     CommentsComments 157
photo

Patrick Picar...

62 Entries |  Patrick Picard
Updated 
RatingsRatings 2     CommentsComments 112
photo

Urs Meli

42 Entries |  Urs Meli
Updated 
No RatingsRatings 0     CommentsComments 48
photo

TexasSwede

109 Entries |  Karl-Henry Martinsso...
Updated 
No RatingsRatings 0     CommentsComments 94

+ Bookmarks

+ Blog Authors  

1 - 1 of 1
  • Previous
  • Next
  • Page   1

Initializing an Array in LotusScript

Peter Presnell |   | Tags:  arrays lotusscript | Comments (2)  |  Visits (754)
Whilst most modern programming languages support an away to initialize an array in a single statement, LotusScript does not have a simple way of creating an array and assigning values to elements in the array.  The creation and initialization of an array typically requires code similar to the following:-

Dim Month(12) As String
Month(1) = "JAN"
Month(2) = "FEB"
...
Month(12) = "DEC"


Whilst split is an option, it does not work for numbers and dates.  Eventually this bugged me enough that I searched for a way to initialize an array such as the above in a single statement. To make my code "easy" to read I have created an Array function which takes a string and evaluates it using @Formulae (which does allow a "List" to be assigned).

I can now write a single LS statement such as

Months = Array({"JAN":"FEB":"MAR":"APR":"MAY":"JUN":"JUL":"AUG":"SEP":"OCT":"NOV":"DEC"})

This works for text, numeric, and date values (but not complex data objects).

The code for the Array function is as follows:-

'/**
' * Returns an array populated with initial values
' *
' * @author Peter Presnell
' * @param Source The initial values separated by colon
' * @return An array created from the initial values
' */

Function Array(Source As String) As Variant
Dim MyArray(0) As String
Try:
On Error Goto Catch
Array = Evaluate(Source$)

Exit Function
Catch:
Stop
MyArray(0) = Source$
Array = MyArray
Exit Function

End Function
No RatingsRatings 0

  • Previous
  • Next
Jump to page of 1
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About