Issue 74824 - Problems with array dimensions
Summary: Problems with array dimensions
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-23 20:06 UTC by cptkirk
Modified: 2017-05-20 11:29 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Contains the files described (4.50 KB, application/x-tar)
2007-02-23 20:11 UTC, cptkirk
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description cptkirk 2007-02-23 20:06:10 UTC
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
Comment 1 cptkirk 2007-02-23 20:11:22 UTC
Created attachment 43323 [details]
Contains the files described
Comment 2 noel.power 2007-02-26 11:50:55 UTC
-> ab 
Comment 3 noel.power 2007-02-26 11:52:28 UTC
try again to reassign
Comment 4 ab 2007-02-28 13:15:12 UTC
STARTED, OOo 2.x

ab->cptkirk: Thanks, but it would be nice if in the future you could submit
one issue for each single problem. Issues like this containing many sub 
issues are difficult to handle.
Comment 5 Mathias_Bauer 2007-12-04 14:57:39 UTC
basic and scripting issues now should be assigned to component "scripting"
Comment 6 Martin Hollmichel 2007-12-07 12:13:46 UTC
set target to 3.x according to http://wiki.services.openoffice.org/wiki/Target_3x
Comment 7 Marcus 2017-05-20 11:29:44 UTC
Reset assigne to the default "issues@openoffice.apache.org".