Issue 26591 - Starbasic Assignment Data(i)=ARRAY(j) inconsistent
Summary: Starbasic Assignment Data(i)=ARRAY(j) inconsistent
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.1.1RC
Hardware: PC Windows 2000
: P3 Trivial (vote)
Target Milestone: ---
Assignee: ab
QA Contact: issues@sc
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-16 21:36 UTC by dfrench
Modified: 2013-08-07 15:15 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description dfrench 2004-03-16 21:36:46 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.
Comment 1 frank 2004-03-17 10:03:03 UTC
Hi Skotty,

could you have a look at this please ?

Frank
Comment 2 joerg.skottke 2004-03-23 10:02:00 UTC
Confirmed - this is strange
Target -> 2.0
Status -> new
Comment 3 joerg.skottke 2004-03-23 10:02:58 UTC
owner -> ab
Comment 4 ab 2004-03-23 15:25:39 UTC
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))
Comment 5 ab 2005-01-25 15:58:20 UTC
-> Closed