Bug 111732 - Basic Function returning an array - only first value is displayed in spreadsheet
Summary: Basic Function returning an array - only first value is displayed in spreadsheet
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.3.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-12 16:14 UTC by nib70776
Modified: 2017-09-06 17:00 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nib70776 2017-08-12 16:14:17 UTC
Description:

I have the following Basic function:
Function test(a as double, b as double, c as double, d as double) as variant
	test = Array(a*20,b*2,c*2,d*2)
end Function

If I enter in cells B1: 1, B2: 2, B3: 3, B4: 4 and in Cells C1:C4 the function =TEST(B4,B5,B6,B7) as array function ({=TEST(B4,B5,B6,B7}) only the first value, i.e. 20 is displayed in Cells C1, C2, C3 and C4.
Correct behaviour would be: C1: 20, C2: 4, C3: 6, C4: 8.
The preview in the function wizard is correct and shows in the field Result: {20,4,6,8}.



Steps to Reproduce:
1. Write the basic function in the libre office basic editor (Module 1):
Function test(a as double, b as double, c as double, d as double) as variant
	test = Array(a*20,b*2,c*2,d*2)
end Function
2. Fill in the numbers 1, 2, 3 , 4 in cells B1, B2, B3, and B4
3. Enter the function =TEST(B4,B5,B6,B7) as array function ({=TEST(B4,B5,B6,B7}) in Cells C1:C4.
4. 20 is displayed in Cells C1, C2, C3 and C4.
5. Correct Behaviour would be: C1: 20, C2: 4, C3: 6, C4: 8
6. The preview in the function wizard is correct and shows in the field Result: {20,4,6,8}.


Actual Results:  
see above

Expected Results:
see above


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Comment 1 Buovjaga 2017-08-30 12:46:38 UTC
I don't understand your array function syntax.

Am I supposed to enter it like you say ({=TEST(B4,B5,B6,B7})? If I do it like that, it just treats it as text.

If I enter it as {=TEST(B4,B5,B6,B7} it gives 80 for C1 and 0 for the others.

Arch Linux 64-bit, KDE Plasma 5
Version: 6.0.0.0.alpha0+
Build ID: 507247697dc6c4a41fe17a29d522511f97040738
CPU threads: 8; OS: Linux 4.12; UI render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on August 29th 2017
Comment 2 nib70776 2017-09-05 12:29:08 UTC
By entering the array function TEST(B4,B5,B6,B7) if refer to the following process:
- Mark cells C1:C4
- fill in: =TEST(B4,B5,B6,B7)
- press shift+ctrl+enter simultaneously
- you see in all 4 cells c1 to c4 {=TEST(B4,B5,B6,B7)} in the input line
- the spreadsheet displays in c1, c2, c3 and c4 20 instead of c1: 20, c2: 4 c3: 6, c4: 8
Comment 3 GerardF 2017-09-05 13:25:43 UTC
Your basic formula returns an online array, not column.
Enter =TEST(B4,B5,B6,B7) in C1 (only C1 selected) and valid with Ctrl+Shift+Enter and you get expected result in C1:F1.
Comment 4 Buovjaga 2017-09-06 07:15:14 UTC
(In reply to GerardF from comment #3)
> Your basic formula returns an online array, not column.
> Enter =TEST(B4,B5,B6,B7) in C1 (only C1 selected) and valid with
> Ctrl+Shift+Enter and you get expected result in C1:F1.

Well it seems we can close as NOTABUG..
Comment 5 nib70776 2017-09-06 17:00:43 UTC
Thanks,
sorry for bothering