GNOME Bugzilla – Bug 323550
CHOOSE can return a ref, and does iteration for array indicies
Last modified: 2018-05-22 13:13:13 UTC
http://www.ecs.soton.ac.uk/~njl98r/excel/choose.xls Worked in 1.4.x but now CHOOSE() function won't load from Excel XLS. (gnumeric:20547): gnumeric:read_expr-WARNING **: EXCEL : Unhandled PTG 0x0. formula data : (NOT shared) 0 | 1e 2 0 19 4 4 0 a 0 14 0 1e 0 28 0 37 | .............(.7 10 | 0 17 3 0 31 73 74 19 8 26 0 17 3 0 32 6e | ....1st..&....2n 20 | 64 19 8 1c 0 17 3 0 33 72 64 19 8 12 0 17 | d.......3rd..... 30 | 8 0 46 69 6e 69 73 68 65 64 19 8 3 0 42 5 | ..Finished....B. 40 | 64 0 XX XX XX XX XX XX XX XX XX XX XX XX XX XX | d.************** (gnumeric:20547): gnumeric:read_expr-WARNING **: CHOOSE!B5 : Unknown Formula/Array The above is repeated more or less for all uses of CHOOSE in this test sheet.
Confirmed. (Note, that CHOOSE is a sheet name in the above error message.) My 1.4.3 does not load this without problems, though: CHOOSE!G13 : Hmm, ptgAttr of type 0 ?? I've seen a case where an instance of this with flag A and another with flag 3 bracket a 1x1 array formula. please send us this file. Flags = 0x15 CHOOSE!G13 : Hmm, ptgAttr of type 0 ?? I've seen a case where an instance of this with flag A and another with flag 3 bracket a 1x1 array formula. please send us this file. Flags = 0xC CHOOSE!G13 : Hmm, ptgAttr of type 0 ?? I've seen a case where an instance of this with flag A and another with flag 3 bracket a 1x1 array formula. please send us this file. Flags = 0x3
No warnings now, but after F9, we see #REF in B6. The formula is =sum(A3:choose(3,B3,D3,F3))
I doubt this ever worked. The warnings were not important and I disabled them in the development tree. The real problem which jon_kare just pointed out is that our function interpreter is naive. We bind references too early. FOO(A1) is evaluated by getting the content of A1 and passing it to FOO rather than passing the reference A1 to FOO and having it decide whether it wants the content or the reference. This will require significant core rework to support properly. The 2nd part of the bug is actually fairly simple. Choose is a unique combination of vararg, and array iteration. It will need to specially handle the case where the index is a matrix.
The patch over in bug 613273 is a partial solution to this. With that, it is possible to get a reference from evaluating A1.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnumeric/issues/46.