* I do not understand this error
@ 2007-07-12 6:07 Cecil Westerhof
2007-07-12 6:34 ` Cecil Westerhof
0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2007-07-12 6:07 UTC (permalink / raw)
To: org-mode
I have the following table:
|---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
| | datum | kmstand | prijs/l | liters | dagen | prijs | km's | prijs/km | km/l |
|---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
| # | | 155111 | | | | | | | |
| # | 2007-07-09 | 156146 | 102.2 | 62.25 | #ERROR | 63.62 | 1035 | 6.147 | 16.627 |
| # | 2007-09-11 | 6953 | 97.8 | 47.75 | #ERROR | 46.70 | Verkeerde kmstand | | |
| # | | | | | #ERROR | | | | |
|---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
#+TBLFM: $6='(if (and (not (check-if-after-hline)) (nz @-1$2) (nz $2)) (- (time-to-days (org-read-date t t "$2")) (time-to-days (org-read-date t t "@-1$2"))) "");S::$7='(if (and (nz $4) (nz $5)) (format "%.2f" (/ (* $4 $5) 100)) "");N::$8='(if (and (nz @-1$3) (nz $3)) (if (> $3 @-1$3) (- $3 @-1$3) (if (not (check-if-after-hline)) "Verkeerde kmstand" "")) "");N::$9='(if (and (nz $8) (nz $7)) (format "%.3f" (/ (* $7 100) $8)) "");N::$10='(if (and (nz $8) (nz $5)) (format "%.3f" (/ $8 $5)) "");N
With debug I get:
Substitution history of formula
Orig: '(if (and (not (check-if-after-hline)) (nz @-1$2) (nz $2)) (- (time-to-days (org-read-date t t "$2")) (time-to-days (org-read-date t t "@-1$2"))) "");S
$xyz-> '(if (and (not (check-if-after-hline)) (nz @-1$2) (nz $2)) (- (time-to-days (org-read-date t t "$2")) (time-to-days (org-read-date t t "@-1$2"))) "")
@r$c-> '(if (and (not (check-if-after-hline)) (nz #(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg))) (nz $2)) (- (time-to-days (org-read-date t t "$2")) (time-to-days (org-read-date t t "#(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg))"))) "")
$1-> '(if (and (not (check-if-after-hline)) (nz #(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg))) (nz #("2007-07-09" 0 3 (hilit-chg hilit-chg lazy-lock t) 3 5 (hilit-chg hilit-chg lazy-lock t) 5 6 (hilit-chg hilit-chg lazy-lock t) 6 8 (hilit-chg hilit-chg lazy-lock t) 8 9 (hilit-chg hilit-chg lazy-lock t) 9 10 (hilit-chg hilit-chg lazy-lock t)))) (- (time-to-days (org-read-date t t "#("2007-07-09" 0 3 (hilit-chg hilit-chg lazy-lock t) 3 5 (hilit-chg hilit-chg lazy-lock t) 5 6 (hilit-chg hilit-chg lazy-lock t) 6 8 (hilit-chg hilit-chg lazy-lock t) 8 9 (hilit-chg hilit-chg lazy-lock t) 9 10 (hilit-chg hilit-chg lazy-lock t))")) (time-to-days (org-read-date t t "#(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg))"))) "")
Result: #ERROR
Format: NONE
Final: #ERROR
If I use the code after $1, I get:
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p #(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg)))
=(#(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg)) 0)
(not (= n 0))
nz(#(" " 0 12 (lazy-lock t face org-table hilit-chg hilit-chg)))
(and (not (check-if-after-hline)) (nz #(" " 0 12 ...)) (nz #("2007-07-09" 0 3 ... 3 5 ... 5 6 ... 6 8 ... 8 9 ... 9 10 ...)))
(if (and (not ...) (nz #(" " 0 12 ...)) (nz #("2007-07-09" 0 3 ... 3 5 ... 5 6 ... 6 8 ... 8 9 ... 9 10 ...))) (- (time-to-days ...) (time-to-days ...)) "")
eval((if (and (not ...) (nz #(" " 0 12 ...)) (nz #("2007-07-09" 0 3 ... 3 5 ... 5 6 ... 6 8 ... 8 9 ... 9 10 ...))) (- (time-to-days ...) (time-to-days ...)) ""))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
recursive-edit()
byte-code(...
debug(error (wrong-type-argument number-or-marker-p #(" " 0 10 (lazy-lock t face org-table hilit-chg hilit-chg))))
=(#(" " 0 10 (lazy-lock t face org-table hilit-chg hilit-chg)) 0)
(not (= n 0))
nz(#(" " 0 10 (lazy-lock t face org-table hilit-chg hilit-chg)))
(and (not (check-if-after-hline)) (nz #(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...)))
(if (and (not ...) (nz #(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) "")
eval((if (and (not ...) (nz #(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) ""))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
recursive-edit()
byte-code(...
debug(error (void-variable nz))
(and (not (check-if-after-hline)) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...)))
(if (and (not ...) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) "")
eval((if (and (not ...) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) ""))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
recursive-edit()
byte-code(...
debug(error (void-variable nz))
(and (not (check-if-after-hline)) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...)))
(if (and (not ...) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) "")
eval((if (and (not ...) nz (#(" " 0 10 ...)) (nz #("20070709" 0 3 ... 3 4 ... 4 5 ... 5 6 ... 6 7 ... 7 8 ...))) (- (time-to-days ...) (time-to-days ...)) ""))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
recursive-edit()
byte-code(...
debug(error (wrong-type-argument integerp nil))
decode-time((nil nil nil 9 7 2007 nil nil nil))
time-to-day-in-year((nil nil nil 9 7 2007 nil nil nil))
eval((time-to-day-in-year (parse-time-string "2007-07-09")))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
recursive-edit()
byte-code(...
debug(error (void-function parse_time_string))
(parse_time_string "2007-07-09")
eval((parse_time_string "2007-07-09"))
eval-last-sexp-1(t)
eval-last-sexp(t)
eval-print-last-sexp()
call-interactively(eval-print-last-sexp)
Where there stands 'byte-code(...', there was some byte-code which I could not copy for one reason or another.
nz is a function which checks if a field is empty (or zero). And this
does not give a problem in the other columns.
So what am I doing wrong?
To be sure, here is the code of nz:
;;; notZero
(defun nz (n)
(interactive "nValue: ")
(not (= n 0.))
)
--
Cecil Westerhof <CecilWesterhof@xs4all.nl>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: I do not understand this error
2007-07-12 6:07 I do not understand this error Cecil Westerhof
@ 2007-07-12 6:34 ` Cecil Westerhof
2007-07-12 7:19 ` Cecil Westerhof
0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2007-07-12 6:34 UTC (permalink / raw)
To: org-mode
Op do, 12-07-2007 te 08:07 +0200, schreef Cecil Westerhof:
> I have the following table:
> |---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
> | | datum | kmstand | prijs/l | liters | dagen | prijs | km's | prijs/km | km/l |
> |---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
> | # | | 155111 | | | | | | | |
> | # | 2007-07-09 | 156146 | 102.2 | 62.25 | #ERROR | 63.62 | 1035 | 6.147 | 16.627 |
> | # | 2007-09-11 | 6953 | 97.8 | 47.75 | #ERROR | 46.70 | Verkeerde kmstand | | |
> | # | | | | | #ERROR | | | | |
> |---+------------+---------+---------+--------+--------+-------+-------------------+----------+--------|
> #+TBLFM: $6='(if (and (not (check-if-after-hline)) (nz @-1$2) (nz $2)) (- (time-to-days (org-read-date t t "$2")) (time-to-days (org-read-date t t "@-1$2"))) "");S::$7='(if (and (nz $4) (nz $5)) (format "%.2f" (/ (* $4 $5) 100)) "");N::$8='(if (and (nz @-1$3) (nz $3)) (if (> $3 @-1$3) (- $3 @-1$3) (if (not (check-if-after-hline)) "Verkeerde kmstand" "")) "");N::$9='(if (and (nz $8) (nz $7)) (format "%.3f" (/ (* $7 100) $8)) "");N::$10='(if (and (nz $8) (nz $5)) (format "%.3f" (/ $8 $5)) "");N
I should not use 'nz', but 'not' and 'equal'. This gives:
|---+------------+---------+---------+--------+-------+-------+-------------------+----------+--------|
| | datum | kmstand | prijs/l | liters | dagen | prijs | km's | prijs/km | km/l |
|---+------------+---------+---------+--------+-------+-------+-------------------+----------+--------|
| # | | 155111 | | | | | | | |
| # | 2007-07-09 | 156146 | 102.2 | 62.25 | -3 | 63.62 | 1035 | 6.147 | 16.627 |
| # | 2007-09-11 | 6953 | 97.8 | 47.75 | 64 | 46.70 | Verkeerde kmstand | | |
| # | | | | | | | | | |
|---+------------+---------+---------+--------+-------+-------+-------------------+----------+--------|
#+TBLFM: $6='(if (and (not (check-if-after-hline)) (not (equal @-1$2 "")) (not (equal $2 ""))) (- (time-to-days (org-read-date t t (concat $2))) (time-to-days (org-read-date t t (concat @-1$2)))) "");S::$7='(if (and (nz $4) (nz $5)) (format "%.2f" (/ (* $4 $5) 100)) "");N::$8='(if (and (nz @-1$3) (nz $3)) (if (> $3 @-1$3) (- $3 @-1$3) (if (not (check-if-after-hline)) "Verkeerde kmstand" "")) "");N::$9='(if (and (nz $8) (nz $7)) (format "%.3f" (/ (* $7 100) $8)) "");N::$10='(if (and (nz $8) (nz $5)) (format "%.3f" (/ $8 $5)) "");N
The only problem is that in the second element of 'dagen' there stands
'-3'. It looks like it that '(not (equal @-1$2 ""))' is not correctly is
evaluated.
--
Cecil Westerhof <CecilWesterhof@xs4all.nl>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: I do not understand this error
2007-07-12 6:34 ` Cecil Westerhof
@ 2007-07-12 7:19 ` Cecil Westerhof
2007-07-13 4:38 ` Carsten Dominik
0 siblings, 1 reply; 4+ messages in thread
From: Cecil Westerhof @ 2007-07-12 7:19 UTC (permalink / raw)
To: org-mode
I have been experimenting a little bit more. I now have the following
table:
|---+------------+---------------+---------------+-----------------------+----------+-------|
| | date | previous date | prev at once | prev with dummy field | row date | dagen |
|---+------------+---------------+---------------+-----------------------+----------+-------|
| # | | | filled | empty | EMPTY | |
| # | 2007-07-09 | | filled | empty | FILLED | -3 |
| # | 2007-09-11 | 2007-07-09 | filled | filled | FILLED | 64 |
| # | | 2007-09-11 | filled | filled | EMPTY | |
| # | 2006-12-31 | | filled | empty | FILLED | -193 |
|---+------------+---------------+---------------+-----------------------+----------+-------|
#+TBLFM: $3='(concat @-1$2);S::$4='(if (not (equal (concat @-1$2) "")) "filled" "empty")::$5='(if (not (equal (concat $3 ) "")) "filled" "empty")::$6='(if (not (equal (concat $2 ) "")) "filled" "empty")::$7='(if (and (not (check-if-after-hline)) (not (equal @-1$2 "")) (not (equal $2 ""))) (- (time-to-days (org-read-date t t (concat $2))) (time-to-days (org-read-date t t (concat @-1$2)))) "");S
When checking for the previous date at once you always get filled. If
the previous date is copied to a field and this field is checked, you
get the expected value.
What is happening here?
Also why is in the column 'row date' everything in caps?
--
Cecil Westerhof <CecilWesterhof@xs4all.nl>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: I do not understand this error
2007-07-12 7:19 ` Cecil Westerhof
@ 2007-07-13 4:38 ` Carsten Dominik
0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2007-07-13 4:38 UTC (permalink / raw)
To: Cecil Westerhof; +Cc: org-mode
On Jul 12, 2007, at 9:19, Cecil Westerhof wrote:
>
>
> When checking for the previous date at once you always get filled. If
> the previous date is copied to a field and this field is checked, you
> get the expected value.
> What is happening here?
Again the formula debugger is showing what happens: In one case "" is
substituted,
in the other case " ", which is not equal to "". I guess you could
call this a bug, I'll see if it can be fixed.
Here is an easy way to check if a field is empty:
(defun not-white (s) (string-match "\\S-" s))
> Also why is in the column 'row date' everything in caps?
Bug, fixed now.
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-13 4:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-12 6:07 I do not understand this error Cecil Westerhof
2007-07-12 6:34 ` Cecil Westerhof
2007-07-12 7:19 ` Cecil Westerhof
2007-07-13 4:38 ` Carsten Dominik
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).