conditional text, conditional sections, Writer 18.104.22.168, the result of evaluating a conditional text or a condition to hide a section seems to depend on whether the variable was previously set in the document, even if the field that set it has since been erased with the "delete" key.
If I write my conditional text field first, and never set the variable referenced therein, it seems to evaluate TRUE. If I then set the variable referenced therein, with a field in front of the conditional text, things work as expected. If I then delete that field, the condition (just the variable) evaluates as FALSE. The only user-apparent difference between the two states is the history of editing the document.
Steps to Reproduce:
1.new writer document.
2.Insert conditional Text using SecondVar (Conditional Text SecondVar -- SecondVar is Set: SecondVar is Clear).
2. Note: SecondVar evaluates to Set
3.Insert Conditional Text using BoolVar (Condtional Text BoolVar -- BoolVar is Set: BoolVar is Clear).
4. Insert fields/more fields, variables, BoolVar, format Boolean, value TRUE
5. Note: BoolVar evaluates to Set.
6. Erase BoolVar field.
7. BoolVar now evaluates to Clear.
7. BoolVar now evaluates to clear, unlike SecondVar, which evaluates to set.
BoolVar should have evaluated to Set, or SecondVar should have evaluated to Clear. (or, alternatively, there should be a way within an expression to tell if a variable has been set or not)
User Profile Reset: No
More generally, LO Writer *should* be consistent in its handling of uninitialized fields when they are tested. I'd like to see a defined() operator, like in the C pre-processor, to test whether a user variable has been set or not.
I have a much longer document where a more complicated conditional (A OR B OR C) evaluates differently on the first and second consecutive evaluation, two lines apart.
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Created attachment 132957 [details]
10 line demo of issue
also demos bug 84148.
seems related to 92662 -- here, a variable has evidently been created with no position in the document.
Use case: A document template uses conditional sections, and is included in multiple master documents with different variable settings.
(In reply to Eric Christenson from comment #0)
> 5. Note: BoolVar evaluates to Set.
At this point, BoolVar evaluated to Clear for me. It stayed that way after I deleted the BoolVar field. I did the steps from scratch, not using the document.
Is this inconsistent enough to confirm or what the heck is expected?
Arch Linux 64-bit
Build ID: aca48f46895811009ec90665d816ef835f0694be
CPU threads: 8; OS: Linux 4.10; UI render: default; VCL: kde4;
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on 30th April 2017
(In reply to Eric Christenson from comment #0)
> conditional text, conditional sections, Writer 22.214.171.124, the result of
> evaluating a conditional text or a condition to hide a section seems to
> depend on whether the variable was previously set in the document, even if
> the field that set it has since been erased with the "delete" key.
The "delete" key does not erase a variable totally but only the "set" field. After the "set" field is erased, go to Insert > Field > More Fields, tab Variables. You will find the variable still listed there. Select it. Then you can use the read cross on the right side of "Name" "Value" to really delete the variable.
The *delete* key doesn't actually *delete* a variable when it deletes the field that sets it?????
Expected: If I set a variable at some point in a field in a document, the value applies from that point forward in the document, and is not available prior to that point. If the field is erased from the document with the delete key (or any other standard way of removing stuff) then Writer acts as if the variable had *never* been set at that point.
126.96.36.199 behavior is a recipe for trouble, not to mention bugs like 84148, which I just confirmed. 92662 requests exactly this, variables with no position in the document, but conceptually at the beginning.
The behavior is counter-intuitive--I have to delete something I inserted once in two places. I have an extra place I have to audit if I want to know all the variables in the document. While I'm at it, what happens if I want to *change* the value of a variable in the middle of a document?
And why do I do these things?.... I am producing a *class* of similar documents and assembling them, if I can, automatically from pieces. I produce a product with multiple options, and the conception is to "turn the crank" and export a document with exactly the options that are present for any given instance of the product.
You are confusing 2 different things: the definition of a variable and the use of this variable.
If deleting a field setting a variable deleted the variable too, it would be impossible to number equations and remove a numbered equation without having to create the numbering variable again.
According comment #4, I close this bug report as NotABug.
Best regards. JBF