You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openoffice.apache.org by bu...@apache.org on 2015/12/29 01:19:28 UTC

[Issue 126758] New: CURRENT() only evaluates first occurrence

https://bz.apache.org/ooo/show_bug.cgi?id=126758

          Issue ID: 126758
        Issue Type: DEFECT
           Summary: CURRENT() only evaluates first occurrence
           Product: Calc
           Version: 4.1.1
          Hardware: Mac
                OS: Mac OS X 10.10
            Status: UNCONFIRMED
          Severity: Blocker
          Priority: P5 (lowest)
         Component: ui
          Assignee: issues@openoffice.apache.org
          Reporter: jim.online@icloud.com

The CURRENT() function seems to only evaluate the first occurrence.

EX:
enter the following in a cell:
=0.5+IF(AND(NOT(CURRENT()>=1);NOT(CURRENT()>=1);NOT(CURRENT()>=1);1;0))

Evaluates to .5 rather than 1.5

EX2:
=0.5+IF(OR(CURRENT()>=0.1;CURRENT()>=1;CURRENT()>= 1);1;0) 
Correctly Evaluates to 1.5

=0.5+IF(OR(CURRENT()>=1;CURRENT()>=0.1;CURRENT()>= 1);1;0)
Evaluates to .5

=0.5+IF(OR(CURRENT()>=1;CURRENT()>=1;CURRENT()>= 0.1);1;0)
Evaluates to .5

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126758] CURRENT() only evaluates first occurrence

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126758

Wolfgang Jäger <ja...@psilosoph.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jag@psilosoph.de

--- Comment #1 from Wolfgang Jäger <ja...@psilosoph.de> ---
As of 2011-09-29 the relevant specification concerning the evaluator for Calc
is http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.odt. It
does not mention a function CURRENT. 
Thus implementing such a function must be based on the general clauses C) and
should obey the requirements of D) in the subchapter "2.3.1 OpenDocument
Formula Evaluator" of the above linked in document. 
Can someone point to the "clear{ly} document" concerning this extension? The
best I could find is the Help text (quoted from AOO V4.1.2): 
"
CURRENT
This function returns the result to date of evaluating the formula of which it
is a part (in other words the result as far as that evaluation has got). Its
main use is together with the STYLE() function to apply selected styles to a
cell depending on the cell content.
Syntax
CURRENT()
Example
=1+2+CURRENT()
The example returns 6. The formula is calculated from left to right as: 1 + 2
equals 3, giving the result to date when CURRENT() is encountered; CURRENT()
therefore yields 3, which is added to the original 3 to give 6.
=A2+B2+STYLE(IF(CURRENT()>10;"Red";"Default"))
The example returns A2 + B2 (STYLE returns 0 here). If this sum is greater than
10, the style Red is applied to the cell. See the STYLE function for more
explanation.
="choo"&CURRENT()
The example returns choochoo.
"
Obviously this can only apply to an evaluation using exactly one accumulator
and not needing any postponing of operations. Only the second example of the
Help text may assure that the previously calculated partial result must still
be accessible when a condition is started to evaluate. Changing it into 
=A2+B2+STYLE(IF(10<CURRENT();"Red";"Default")) will change the result, and we
should expect that. We have a very fragile situation and even the second
example of the above mentioned Help depends on not initialising the accumulator
anew when the partial result is pushed on the stack (supposed things are
roughly done this traditional way).
To get it a bit clearer suspend using logical expressions, and try:
=5*(CURRENT()+2)
=5*(2+CURRENT())
=5*(CURRENT()+2+CURRENT())

I could not find an AOO documentation containing more detail (or in fact
something at all). (The most recent LibO CalcGuide simply puts it this way:
"CURRENT() Calculates the current value of a formula at the actual position.")

In consequence we should not judge the reported behaviouir a bug. We have
instead a serious flaw concerning specification and documentation - and a
possibly too rash implementation of an extension.

-- 
You are receiving this mail because:
You are the assignee for the issue.

[Issue 126758] CURRENT() only evaluates first occurrence

Posted by bu...@apache.org.
https://bz.apache.org/ooo/show_bug.cgi?id=126758

--- Comment #2 from Wolfgang Jäger <ja...@psilosoph.de> ---
Here an additional attemp:

Let me modify the first example of the OP to
=0.5+IF(AND(NOT(CURRENT()>=1);NOT(CURRENT()<>1);CURRENT()=1);1;0)
It will return 1.5 . 
Why? Having evaluated the "NOT(CURRENT()>=1)" on the first parameter position
of AND the result kept in (kind of) the accumulator will be 1 (meaning TRUE).
This is the "current" value still present when the evaluation of the second
parameter is starting. Now this intermediary result is returned by CURRENT. The
second parameter will evaluate to TRUE again for this reason. I cannot judge
whether the CURRENT value passed to the third parameter is now the TRUE
returned for the second one or the TRUE already accumulating two TRUEs under
the rule of AND. This is VERY implementation dependent.

Based on the undocumented utilisation of AND as a logical infix operator we may
also look at
=0.5+IF((CURRENT()<1) AND (CURRENT()=1) AND (CURRENT()=1);1;0) 
to emphasise the similarity of the example to the arithmetic one from my above
comment.

-- 
You are receiving this mail because:
You are the assignee for the issue.