|
From: | Maxim Nikulin |
Subject: | Re: Bug: Can’t assign to hline relative reference |
Date: | Thu, 29 Oct 2020 19:40:37 +0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
2020-10-23 Dante Catalfamo wrote:
That seems to work for the most part, but now I'm experiencing a strange difference when evaluating. If I use a formula like#+TBLFM:@2$3..@23$3=if($2!=0,12*$2,$3);%.2f::@24$2=vsum(@I..@II);%.2f::@24$3=vsum(@I..@II);%.2fThe column gets evaluated first, then the sum at the bottom gets evaluated, resulting in what I'd expect. But if I use a formula like #+TBLFM:@<<$3..@>>$3=if($2!=0,12*$2,$3);%.2f::@24$2=vsum(@I..@II);%.2f::@24$3=vsum(@I..@II);%.2f The sum gets calculated first, and the column after, meaning the sum doesn't reflect any changes made before calculation. I find this pretty strange considering the formulas are in the same order. Do formulas involving relative references get calculated last for some reason?
Interesting... However my curiosity is not strong enough to find appropriate place in the code.
Either I never tried such combination of references (I use @>$2=... for the last row) or I have not expected reliable evaluation order and just hit C-c C-c several times.
It seems that single cell formulas are calculated later than ranges | a | c | b | |---+---+---| | 2 | | | | 3 | | | | 4 | | | | 5 | | | | 6 | | | | 7 | | | |---+---+---| | | | |#+TBLFM: @<<$3..@>>$3=$1*2 :: @<<$2..@<<<$2=$3*3 :: @5$2..@6$2=$3*4 :: @4$2=$3*5 :: @>>$2=$3*6
| a | c | b | |---+----+----| | 2 | 0 | 4 | | 3 | 0 | 6 | | 4 | 0 | 8 | | 5 | 0 | 10 | | 6 | 0 | 12 | | 7 | 84 | 14 | |---+----+----| | | | |#+TBLFM: @<<$3..@>>$3=$1*2 :: @<<$2..@<<<$2=$3*3 :: @5$2..@6$2=$3*4 :: @4$2=$3*5 :: @>>$2=$3*6
Notice zeroes for @<<..@<<< but not for @>>. Even more funny that @>>>>>>>$2..@>>>>>>$2=$3 instead of @<<$3..@<<<$3 give non-zero values for the second and third rows. Anyway I do not plan to memorize such rules.
By the way, I have noticed that @<<$3..@>>$3=... likely could be replaced by just $3=... and it is evaluated quite early in such form. Skimming through the manual previous times, I missed the point of "column formulas" https://orgmode.org/manual/Column-formulas.html or
[[info:org#Column formulas]] and have noticed the details just today.
[Prev in Thread] | Current Thread | [Next in Thread] |