emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Making a list to string
@ 2007-07-11 20:43 Cecil Westerhof
  2007-07-11 21:54 ` Eddward DeVilla
  0 siblings, 1 reply; 7+ messages in thread
From: Cecil Westerhof @ 2007-07-11 20:43 UTC (permalink / raw)
  To: org-mode

I have the following table:
        |---+------------+---------------------------+------------+------------------------------------------|
        |   |      datum |                from datum | hard coded |                                          |
        |---+------------+---------------------------+------------+------------------------------------------|
        | # | 2007-01-01 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 49, 45, 48, 49] |
        | # | 2007-07-09 |                       192 |        190 | [50, 48, 48, 55, 45, 48, 55, 45, 48, 57] |
        | # | 2007-07-11 |                       192 |        192 | [50, 48, 48, 55, 45, 48, 55, 45, 49, 49] |
        | # | 2007-09-11 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 57, 45, 49, 49] |
        | # |   20071012 |                       192 |          1 | [50, 48, 48, 55, 49, 48, 49, 50]         |
        |---+------------+---------------------------+------------+------------------------------------------|
        #+TBLFM: $3='(time-to-day-in-year (org-read-date t t "$2"));N::$5="$2"::@2$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t "2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t "2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::

The column 'from datum' does not get the right values. The last column
shows why. "$2" gives a list of ASCII values of the string instead of
the string. This makes that org-read-data gets 50 as a parameter instead
of the string representing a date. How do I convert this list back to
the string it is representing?

-- 
Cecil Westerhof <CecilWesterhof@xs4all.nl>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-11 20:43 Making a list to string Cecil Westerhof
@ 2007-07-11 21:54 ` Eddward DeVilla
  2007-07-11 21:59   ` Eddward DeVilla
  0 siblings, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2007-07-11 21:54 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: org-mode

Is this any better.  I don't think it's entirely right yet.

   |---+------------+------------+------------+------------|
   |   |      datum | from datum | hard coded |            |
   |---+------------+------------+------------+------------|
   | # | 2007-01-01 |          1 |          1 | 2007-01-01 |
   | # | 2007-07-09 |        190 |        190 | 2007-07-09 |
   | # | 2007-07-11 |        192 |        192 | 2007-07-11 |
   | # | 2007-09-11 |        254 |          1 | 2007-09-11 |
   | # |   20071012 |        192 |          1 |   20071012 |
   |---+------------+------------+------------+------------|
#+TBLFM: $3='(time-to-day-in-year (org-read-date t t (concat
$2)))::$5='(concat $2)::@2$4='(time-to-day-in-year (org-read-date t t
"2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t
"2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t
"2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t
"2007-01-01"));N


On 7/11/07, Cecil Westerhof <CecilWesterhof@xs4all.nl> wrote:
> I have the following table:
>         |---+------------+---------------------------+------------+------------------------------------------|
>         |   |      datum |                from datum | hard coded |                                          |
>         |---+------------+---------------------------+------------+------------------------------------------|
>         | # | 2007-01-01 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 49, 45, 48, 49] |
>         | # | 2007-07-09 |                       192 |        190 | [50, 48, 48, 55, 45, 48, 55, 45, 48, 57] |
>         | # | 2007-07-11 |                       192 |        192 | [50, 48, 48, 55, 45, 48, 55, 45, 49, 49] |
>         | # | 2007-09-11 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 57, 45, 49, 49] |
>         | # |   20071012 |                       192 |          1 | [50, 48, 48, 55, 49, 48, 49, 50]         |
>         |---+------------+---------------------------+------------+------------------------------------------|
>         #+TBLFM: $3='(time-to-day-in-year (org-read-date t t "$2"));N::$5="$2"::@2$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t "2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t "2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::
>
> The column 'from datum' does not get the right values. The last column
> shows why. "$2" gives a list of ASCII values of the string instead of
> the string. This makes that org-read-data gets 50 as a parameter instead
> of the string representing a date. How do I convert this list back to
> the string it is representing?
>
> --
> Cecil Westerhof <CecilWesterhof@xs4all.nl>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-11 21:54 ` Eddward DeVilla
@ 2007-07-11 21:59   ` Eddward DeVilla
  2007-07-12  5:23     ` Cecil Westerhof
  0 siblings, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2007-07-11 21:59 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: org-mode

I take that back.  I think it is right.  I thought hard coded and
frodatum were supposed to match.  Unfortunately, it looks like the
mailed mangles the formula line.

On 7/11/07, Eddward DeVilla <eddward@gmail.com> wrote:
> Is this any better.  I don't think it's entirely right yet.
>
>    |---+------------+------------+------------+------------|
>    |   |      datum | from datum | hard coded |            |
>    |---+------------+------------+------------+------------|
>    | # | 2007-01-01 |          1 |          1 | 2007-01-01 |
>    | # | 2007-07-09 |        190 |        190 | 2007-07-09 |
>    | # | 2007-07-11 |        192 |        192 | 2007-07-11 |
>    | # | 2007-09-11 |        254 |          1 | 2007-09-11 |
>    | # |   20071012 |        192 |          1 |   20071012 |
>    |---+------------+------------+------------+------------|
> #+TBLFM: $3='(time-to-day-in-year (org-read-date t t (concat
> $2)))::$5='(concat $2)::@2$4='(time-to-day-in-year (org-read-date t t
> "2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t
> "2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t
> "2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t
> "2007-01-01"));N
>
>
> On 7/11/07, Cecil Westerhof <CecilWesterhof@xs4all.nl> wrote:
> > I have the following table:
> >         |---+------------+---------------------------+------------+------------------------------------------|
> >         |   |      datum |                from datum | hard coded |                                          |
> >         |---+------------+---------------------------+------------+------------------------------------------|
> >         | # | 2007-01-01 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 49, 45, 48, 49] |
> >         | # | 2007-07-09 |                       192 |        190 | [50, 48, 48, 55, 45, 48, 55, 45, 48, 57] |
> >         | # | 2007-07-11 |                       192 |        192 | [50, 48, 48, 55, 45, 48, 55, 45, 49, 49] |
> >         | # | 2007-09-11 |                       192 |          1 | [50, 48, 48, 55, 45, 48, 57, 45, 49, 49] |
> >         | # |   20071012 |                       192 |          1 | [50, 48, 48, 55, 49, 48, 49, 50]         |
> >         |---+------------+---------------------------+------------+------------------------------------------|
> >         #+TBLFM: $3='(time-to-day-in-year (org-read-date t t "$2"));N::$5="$2"::@2$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t "2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t "2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t "2007-01-01"));N::
> >
> > The column 'from datum' does not get the right values. The last column
> > shows why. "$2" gives a list of ASCII values of the string instead of
> > the string. This makes that org-read-data gets 50 as a parameter instead
> > of the string representing a date. How do I convert this list back to
> > the string it is representing?
> >
> > --
> > Cecil Westerhof <CecilWesterhof@xs4all.nl>
> >
> >
> >
> > _______________________________________________
> > Emacs-orgmode mailing list
> > Emacs-orgmode@gnu.org
> > http://lists.gnu.org/mailman/listinfo/emacs-orgmode
> >
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-11 21:59   ` Eddward DeVilla
@ 2007-07-12  5:23     ` Cecil Westerhof
  2007-07-12  6:04       ` Eddward DeVilla
  2007-07-13 13:47       ` Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: Cecil Westerhof @ 2007-07-12  5:23 UTC (permalink / raw)
  To: org-mode

Op wo, 11-07-2007 te 16:59 -0500, schreef Eddward DeVilla:
> I take that back.  I think it is right.  I thought hard coded and
> frodatum were supposed to match.  Unfortunately, it looks like the
> mailed mangles the formula line.
> 
> On 7/11/07, Eddward DeVilla <eddward@gmail.com> wrote:
> > Is this any better.  I don't think it's entirely right yet.
> >
> >    |---+------------+------------+------------+------------|
> >    |   |      datum | from datum | hard coded |            |
> >    |---+------------+------------+------------+------------|
> >    | # | 2007-01-01 |          1 |          1 | 2007-01-01 |
> >    | # | 2007-07-09 |        190 |        190 | 2007-07-09 |
> >    | # | 2007-07-11 |        192 |        192 | 2007-07-11 |
> >    | # | 2007-09-11 |        254 |          1 | 2007-09-11 |
> >    | # |   20071012 |        192 |          1 |   20071012 |
> >    |---+------------+------------+------------+------------|
> > #+TBLFM: $3='(time-to-day-in-year (org-read-date t t (concat
> > $2)))::$5='(concat $2)::@2$4='(time-to-day-in-year (org-read-date t t
> > "2007-01-01"));N::@3$4='(time-to-day-in-year (org-read-date t t
> > "2007-07-09"));N::@4$4='(time-to-day-in-year (org-read-date t t
> > "2007-07-11"));N::@5$4='(time-to-day-in-year (org-read-date t t
> > "2007-01-01"));N

Yes, it looks like it works completly. (What I am missing is a knowledge
of Lisp. Thus that will come.)

One thing bugs me. I am used to end a formula ending with ';N'.
Sometimes if you do not do this, this geves an error. But in this case
this gives an error:
        Substitution history of formula
        Orig:   '(time-to-day-in-year (org-read-date t t (concat $2)))
        $xyz->  '(time-to-day-in-year (org-read-date t t (concat $2)))
        @r$c->  '(time-to-day-in-year (org-read-date t t (concat $2)))
        $1->    '(time-to-day-in-year (org-read-date t t (concat 2007)))
        Result: #ERROR
        Format: NONE
        Final:  #ERROR
When using nothing after the formula, I get:
        Substitution history of formula
        Orig:   '(time-to-day-in-year (org-read-date t t (concat $2)))
        $xyz->  '(time-to-day-in-year (org-read-date t t (concat $2)))
        @r$c->  '(time-to-day-in-year (org-read-date t t (concat $2)))
        $1->    '(time-to-day-in-year (org-read-date t t (concat #("2007-01-01" 0 1 (hilit-chg hilit-chg lazy-lock t) 1 2 (hilit-chg hilit-chg lazy-lock t) 2 3 (hilit-chg hilit-chg lazy-lock t) 3 4 (hilit-chg hilit-chg lazy-lock t) 4 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)))))
        Result: 1
        Format: NONE
        Final:  1
And when I put ';S' after the formula, I get the same as with nothing
after the formula.
Why this error by ';N'?
Also what is the meaning of the strange expansion by concat? Maybe not
neccesary, but I like to understand what is happening.

-- 
Cecil Westerhof <CecilWesterhof@xs4all.nl>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-12  5:23     ` Cecil Westerhof
@ 2007-07-12  6:04       ` Eddward DeVilla
  2007-07-12  6:10         ` Cecil Westerhof
  2007-07-13 13:47       ` Carsten Dominik
  1 sibling, 1 reply; 7+ messages in thread
From: Eddward DeVilla @ 2007-07-12  6:04 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: org-mode

On 7/12/07, Cecil Westerhof <CecilWesterhof@xs4all.nl> wrote:
> Yes, it looks like it works completly. (What I am missing is a knowledge
> of Lisp. Thus that will come.)
>
> One thing bugs me. I am used to end a formula ending with ';N'.

By default the field values are passed to the lisp expression as a
string.  If you want it to be passed as a number you need the ;N.  So
if @3$4 = 123:

'(foo @3$4)  => '(foo "123")
'(foo @3$4);N => '(foo 123)

Edd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-12  6:04       ` Eddward DeVilla
@ 2007-07-12  6:10         ` Cecil Westerhof
  0 siblings, 0 replies; 7+ messages in thread
From: Cecil Westerhof @ 2007-07-12  6:10 UTC (permalink / raw)
  To: org-mode

Op do, 12-07-2007 te 01:04 -0500, schreef Eddward DeVilla:
> On 7/12/07, Cecil Westerhof <CecilWesterhof@xs4all.nl> wrote:
> > Yes, it looks like it works completly. (What I am missing is a knowledge
> > of Lisp. Thus that will come.)
> >
> > One thing bugs me. I am used to end a formula ending with ';N'.
> 
> By default the field values are passed to the lisp expression as a
> string.  If you want it to be passed as a number you need the ;N.  So
> if @3$4 = 123:
> 
> '(foo @3$4)  => '(foo "123")
> '(foo @3$4);N => '(foo 123)

I remember Carsten mentioning something about this.
I would expect the ';N' have influence on the output, not on the input.

-- 
Cecil Westerhof <CecilWesterhof@xs4all.nl>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Making a list to string
  2007-07-12  5:23     ` Cecil Westerhof
  2007-07-12  6:04       ` Eddward DeVilla
@ 2007-07-13 13:47       ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2007-07-13 13:47 UTC (permalink / raw)
  To: Cecil Westerhof; +Cc: org-mode


On Jul 12, 2007, at 7:23, Cecil Westerhof wrote:
> And when I put ';S' after the formula, I get the same as with nothing
> after the formula.
> Why this error by ';N'?
> Also what is the meaning of the strange expansion by concat? Maybe not
> neccesary, but I like to understand what is happening.

When you put "N", each field is converted into a number before
it is interpolated into the formula. So "2007-02-02" becomes
2007, and it is inserted *as a number* into the Lisp form.
concat is a function that concatenates string - it cannot handle
numbers, so it throws an error.

- Carsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-07-13 13:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-11 20:43 Making a list to string Cecil Westerhof
2007-07-11 21:54 ` Eddward DeVilla
2007-07-11 21:59   ` Eddward DeVilla
2007-07-12  5:23     ` Cecil Westerhof
2007-07-12  6:04       ` Eddward DeVilla
2007-07-12  6:10         ` Cecil Westerhof
2007-07-13 13:47       ` 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).