Manage Learn to apply best practices and optimize your operations.

Array Initialize

Assign a great number of elements to an array

You can view feedback to this tip!

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 ?l?ments
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



FEEDBACK:

  • This is beautiful work by Fabient, but there are a couple of "gotchas" in making it work.

    The following will correctly set up and call the code:

    Dim Chaine As String
    Dim Array(7) As String
    
    'Vary the 7 according to
    'the elements you plan to put
    'into the array.
    'The posted code doesn't
    'declare the array length
    'producing an out of bounds error
    'after the first element
    
    Chaine = "Lundi,Mardi,Mercredi,Jeudi,Vendredi,Samedi,Dimanche"
    ' --> 7 elements
        
    Call Arrayass(Array,Chaine)
    'show the results on the status bar
    For myi = 1 To 7
    Print Array(myi)
    Next

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close