Assign Elements to an Array / Script Table

Author: Tripp W Black

Created: 07/05/2000 at 11:23 AM

 

Category:
Notes Developer Tips
LotusScript

---------------------------------------------------------------
COOL DOMINO PROGRAMMING TIP
---------------------------------------------------------------
Title: Array Initialize
Author: Fabien Mancino, Independent

In LotusScript, it's not possible to initialize a one
dimension table in one step with more than one
element. Thanks to this script, you can assign a
great number of elements to an array and this is in
two line code!

----------------------------------------------
Example :

Dim Chaine As String
Dim Array() As String ' --> Tableau de 7 lments
Chaine = "Lundi,Mardi,Mercredi,Jeudi,Vendredi,
Samedi,Dimanche" ' --> 7 element

Call Arrayass(Array,String)
-------------------------------------------

After execution, the Array variable contents is:
[[Lundi][Mardi][Mercredi][Jeudi][Vendredi][Samedi]
[Dimanche]]

Array(1)=Lundi
Array(5)=Vendredi
Array(7)=Dimanche

Note : The separator must be a "," or a ";"

Sub Arrayass(Tabl() As String, Chaine As String)

Dim i,start,Element As Integer
Dim temp As String

start=1
Element=1

Do

i=1
Do
temp=Mid$(Chaine,start,i)
i=i+1
Loop Until Right(temp,1)="," Or Right(temp,1)=
";" Or start+i-2=Len(Chaine)

Tabl(Element)=LTrim$(Left(temp,Len(temp)-1 +
(start+i-2=Len(Chaine))*(-1)))
start=start+i-1
Element=Element+1

Loop Until Len(Chaine)=start-1

End Sub


previous page