Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Blogs

photo

Yellow is the...

54 Entries |  Tim Tripcony
Updated 
No Ratings 0     Comments 22
photo

TexasSwede

66 Entries |  Karl-Henry Martinsso...
Updated 
No Ratings 0     Comments 59
photo

Lotus Nut

69 Entries |  Chris Whisonant
Updated 
Ratings 4     Comments 96
photo

Urs Meli

19 Entries |  Urs Meli
Updated 
No Ratings 0     Comments 14
photo

Uh Clem's Adm...

35 Entries |  Chris Mobley
Updated 
Ratings 5     Comments 42

Dogear Bookmarks

.Domino Framework

Blog Authors:  Peter Presnell  

Previous |  Main  | Next

Initializing an Array in LotusScript

Peter Presnell  |     |  Tags:  arrays lotusscript  |  Comments (2)
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

Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.