Apache OpenOffice (AOO) Bugzilla – Issue 26591
Starbasic Assignment Data(i)=ARRAY(j) inconsistent
Last modified: 2013-08-07 15:15:02 UTC
Where Array(i) is used to assign values to an array (required where OOo needs an argument that is an array of arrays), the assignment appears to apply to all the elements but Array(i+1-1) functions as expected. See starbasic macro code below which assigns 11 values to the first sheet of a spreadsheet. Sub works Dim data (0 to 10) oSheet =thiscomponent.Sheets.getByIndex(0) for i= 0 to 10 data(i)=Array(i+1-1) 'there appears to be an issue that requires this rather than Array(i) next Range = oSheet.getCellRangeByposition(0,0,0,10) Range.setDataArray(data()) End Sub Sub worksnot Dim data (0 to 10) oSheet =thiscomponent.Sheets.getByIndex(0) for i= 0 to 10 data(i)=Array(i) '******** next Range = oSheet.getCellRangeByposition(0,0,0,10) Range.setDataArray(data()) End Sub Subroutine works assigns the numbers from 0 to 10 to a1:a11 while worksnot assigns the number 11 to a1:a11.
Hi Skotty, could you have a look at this please ? Frank
Confirmed - this is strange Target -> 2.0 Status -> new
owner -> ab
This is no inconsistancy of the Basic Array function but wrong API usage. According to the com.sun.star.sheet.XCellRangeData specification the method setDataArray expects a sequence< sequence< any > > and "each element of the array must contain a double or a string". As Basic is not able to read the specification the Basic program- mer has to make sure to pass correctly typed values to the API. In the example program the Sub works passes double values because the calculation i+1-1 forces the result to be of type double, whereas in Sub worksnot the i simply stays an integer that later is not accepted by the setDataArray method. So sub works only performs an integer to double conversion in a strange way. The correct way would be like this: data(i)=Array(cdbl(i))
-> Closed