To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=74824
                 Issue #|74824
                 Summary|Problems with array dimensions
               Component|framework
                 Version|OOo 2.1
                Platform|PC
                     URL|
              OS/Version|Windows XP
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|scripting
             Assigned to|npower
             Reported by|cptkirk





------- Additional comments from [EMAIL PROTECTED] Fri Feb 23 20:06:10 +0000 
2007 -------
Everything started while i was trying to initialize a multidimensional array in
Openoffice Basic. The array is quite big and i was trying to initialize it in a
C++ way:

          Option Base 1
    ...
    Dim myArray(8,20) As Single
    ...
    myArray = ( ( 11,  12,  13,  14,  15,  16,  17,  18)  _
                ( 21,  22,  23,  24,  25,  26,  27,  28)  _
                ........................................  _
                (201, 202, 203, 204, 205, 206, 207, 208))

I failed to initialize my array and after a lot of googling i found out nothing.
I concluded that this syntax is not supported and that multidimensional arrays
can only be initialized by the following way:

        myArray(1,1)  = 11
        myArray(1,2)  = 12

I find this syntax quite hard to use, so i wrote a program that initializes my
array by reading the values from a file. The column values are delimited by
whitespace and the rows are delimited by carriage return.

While debugging my program i found some inconveniences :

    * I used the Option Base 1 command in order to start counting from 1.  While
          declaring Dim myArray(2,2)i found out that the dimensions of myArray
are 3x3 while i expected 2x2.
    
    * After using the ReDim tmpArray(iMaxCol),where iMaxCol is a variable i use,
I find out that after redimming tmpArray its dimensions are
(iMaxCol+1)x(iMaxCol+1) and iMaxCol variable is increased by one.
    
    * After using the Split function in order to assign an array of strings to
the tmpArray its dimensions are changed once again (which is understood) but
they are initialized as if Option Base 0 was selected. So i have to modify my
code accordingly.

I'm not even close to being a Basic guru, but i consider these to be bugs. I'm
attaching the basic source code and the testfile i use. This code is doing what
it is supposed to. The inconveniences i described  earlier can be viewed while
watching the program in the debugger step by step. Developed under Windows XP,
Openoffice 2.1, Acer Aspire5020 Laptop (for hardware details).

                                           Keep up the good work guys,
                                                   Costis Hatzopoulos

------------- testfile
11    12/r
21    22/r
EOF
------------- end of testfile

------------- code.bas
' Module: EC3_DB_IPE
' This module defines a simple database for the
' geometric and mechanic properties of the IPE
' family of sections
' The Database is read from a file which should 
' be formatted as follows:
' Column values should be delimited by whitespace
' Row values should be delimited by carriage return 

'All variables should have their type declared explicitely
Option Explicit
Option Base 1

'Issue 1
Dim TestArray(2-1, 2-1) As Double 'Target Array
Dim tmpArray            As String 'Temporary Array

Sub InitializeDB
'This Sub Initializes The Above Array
'from a file

'TODO:
'1. Read filename From Dialog
'2. Handle random files with random format

Dim sFilename As String   'Filename To Open
Dim iNumber   As Integer  'System File Number
Dim iRowCount As Integer  'Line Counter
Dim iColCount As Integer  'Column Counter
Dim iMaxRow   As Integer  'Maximum Rows
Dim iMaxCol   As Integer  'Maximum Columns
Dim sRow      As String   'Temporary Variable
Dim i             As Integer  'Counter

sFilename="F:\testfile"

iMaxRow = UBound(TestArray,1)
iMaxCol = UBound(TestArray,2)

'Temporary Array
'Issue 2
ReDim tmpArray(iMaxCol-1)

iNumber = FreeFile
Open sFilename For Input As #iNumber

Do While Not EOF(iNumber)
        Line Input #iNumber, sRow
        iRowCount = iRowCount + 1
        if iRowCount > iMaxRow Then Exit Do
                
                If sRow <>"" Then
                
                        'Issue 3
                        tmpArray = Split(sRow," ",iMaxCol)
                        
                        For i=1 To iMaxCol
                                TestArray(iRowCount, i) = CDbl(tmpArray(i-1))
                        Next i
                        
            End If
Loop
'If the iRowCount < iMaxRow Do Something

Close #iNumber

End Sub
------------- end of code.bas

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to