emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* what's wrong with this sbe?
@ 2012-03-05 12:51 Myles English
  2012-03-05 14:09 ` Sebastien Vauban
  2012-03-05 14:34 ` Eric Schulte
  0 siblings, 2 replies; 7+ messages in thread
From: Myles English @ 2012-03-05 12:51 UTC (permalink / raw)
  To: emacs-orgmode Mode


Hi,

Please could tell me where I am going wrong with this?  I just can't get
the source block to put a result in the table.

#+name: workingDays
#+BEGIN_SRC emacs-lisp :var hms="0"
(require 'org-timer)
(/ (org-timer-hms-to-secs hms) (* 60 60 8))
#+END_SRC

#+call: workingDays(hms="236:30:00")

#+RESULTS: workingDays(hms="236:30:00")
: 29

| Days   |     H:M:S |
|--------+-----------|
| #ERROR | 236:30:00 |
#+TBLFM: @2$1='(sbe "workingDays" (hms @2$2))


Thanks,

Myles

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

* Re: what's wrong with this sbe?
  2012-03-05 12:51 what's wrong with this sbe? Myles English
@ 2012-03-05 14:09 ` Sebastien Vauban
  2012-03-05 15:29   ` Myles English
  2012-03-05 14:34 ` Eric Schulte
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2012-03-05 14:09 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Myles,

Myles English wrote:
> Please could tell me where I am going wrong with this?  I just can't get
> the source block to put a result in the table.
>
> #+name: workingDays
> #+BEGIN_SRC emacs-lisp :var hms="0"
> (require 'org-timer)
> (/ (org-timer-hms-to-secs hms) (* 60 60 8))
> #+END_SRC
>
> #+call: workingDays(hms="236:30:00")
>
> #+RESULTS: workingDays(hms="236:30:00")
> : 29
>
> | Days   |     H:M:S |
> |--------+-----------|
> | #ERROR | 236:30:00 |
> #+TBLFM: @2$1='(sbe "workingDays" (hms @2$2))

This is because the string you send in the `sbe' call should be
(double-)quoted, as in:

  | Days | H:M:S       |
  |------+-------------|
  |   29 | "236:30:00" |
  #+TBLFM: @2$1='(sbe workingDays (hms @2$2))

This is really annoying for most cases, and dates back from a problem to
distinguish between references and strings, at some point.

I wonder whether this heavy constraint (strings must be enclosed) still
applies or not.

Best regards,
  Seb

PS- No need to quote the function name...

-- 
Sebastien Vauban

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

* Re: what's wrong with this sbe?
  2012-03-05 12:51 what's wrong with this sbe? Myles English
  2012-03-05 14:09 ` Sebastien Vauban
@ 2012-03-05 14:34 ` Eric Schulte
  2012-03-05 17:09   ` Myles English
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2012-03-05 14:34 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode Mode

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

Myles English <mylesenglish@gmail.com> writes:

> Hi,
>
> Please could tell me where I am going wrong with this?  I just can't get
> the source block to put a result in the table.
>
> #+name: workingDays
> #+BEGIN_SRC emacs-lisp :var hms="0"
> (require 'org-timer)
> (/ (org-timer-hms-to-secs hms) (* 60 60 8))
> #+END_SRC
>
> #+call: workingDays(hms="236:30:00")
>
> #+RESULTS: workingDays(hms="236:30:00")
> : 29
>
> | Days   |     H:M:S |
> |--------+-----------|
> | #ERROR | 236:30:00 |
> #+TBLFM: @2$1='(sbe "workingDays" (hms @2$2))
>

Hi Miles,

To force the value of "236:30:00" to be interpreted as a string (rather
than have sbe try to convert it to a number prefix the reference with a
"$" character).  However even doing this your example exposed a bug in
this sbe functionality to which I've just pushed up a fix.  With the
latest version of Org-mode the attached works as expected.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sbe-example.org --]
[-- Type: text/x-org, Size: 405 bytes --]

#+name: workingDays
#+BEGIN_SRC emacs-lisp :var hms="0"
  (require 'org-timer)
  (/ (org-timer-hms-to-secs hms) (* 60 60 8))
#+END_SRC

Note the variable reference is prefixed with a "$" to ensure that it
is interpreted as a string.  See the `sbe' documentation for full
`sbe' usage information.

| Days |     H:M:S |
|------+-----------|
|   29 | 236:30:00 |
#+TBLFM: @2$1='(sbe workingDays (hms $@2$2))

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


Cheers,

>
>
> Thanks,
>
> Myles
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

* Re: what's wrong with this sbe?
  2012-03-05 14:09 ` Sebastien Vauban
@ 2012-03-05 15:29   ` Myles English
  0 siblings, 0 replies; 7+ messages in thread
From: Myles English @ 2012-03-05 15:29 UTC (permalink / raw)
  To: Sebastien Vauban, emacs-orgmode


Thanks Seb,

* TODO Fix the word wrapping in my emails               :gnus:
  <SCHEDULED: ASAP>

>> On Mon, 05 Mar 2012 15:09:49 +0100, Sebastien Vauban said:

  > Hi Myles, Myles English wrote:
  >> Please could tell me where I am going wrong with this?  I just
  >> can't get the source block to put a result in the table.
  >> 
  >> #+name: workingDays #+BEGIN_SRC emacs-lisp :var hms="0" (require
  >> 'org-timer) (/ (org-timer-hms-to-secs hms) (* 60 60 8)) #+END_SRC
  >> 
  >> #+call: workingDays(hms="236:30:00")
  >> 
  >> #+RESULTS: workingDays(hms="236:30:00") : 29
  >> 
  >> | Days | H:M:S | |--------+-----------| | #ERROR |
  >> 236:30:00 | #+TBLFM: @2$1='(sbe "workingDays" (hms @2$2))

  > This is because the string you send in the `sbe' call should be
  > (double-)quoted, as in:

  >   | Days | H:M:S | |------+-------------| | 29 |
  > "236:30:00" | #+TBLFM: @2$1='(sbe workingDays (hms @2$2))

  > This is really annoying for most cases, and dates back from a
  > problem to distinguish between references and strings, at some
  > point.

Yes it is quite annoying.  After your help I tried various combinations
of (quote),(print),(string),(number-to-string) and (concat), both in the
TBLFM line and in the source block but found that this is the only way
to get a slightly unsatisfactory result:

| Days |     H:M:S |             |
|------+-----------+-------------|
|   29 | 236:30:00 | "236:30:00" |
|      |           |             |
#+TBLFM: @2$3='(print (concat "\"" @2$2 "\""))::@2$1='(sbe workingDays (hms @2$3))


  > I wonder whether this heavy constraint (strings must be enclosed)
  > still applies or not.

  > Best regards, Seb

  > PS- No need to quote the function name...

  > -- Sebastien Vauban

Thanks again,

Myles

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

* Re: what's wrong with this sbe?
  2012-03-05 14:34 ` Eric Schulte
@ 2012-03-05 17:09   ` Myles English
  2012-03-05 17:17     ` Myles English
  2012-03-05 17:46     ` Eric Schulte
  0 siblings, 2 replies; 7+ messages in thread
From: Myles English @ 2012-03-05 17:09 UTC (permalink / raw)
  To: Eric Schulte, emacs-orgmode Mode


>> On Mon, 05 Mar 2012 07:34:49 -0700, Eric Schulte said:

  > Myles English <mylesenglish@gmail.com> writes:
  >> Hi,
  >> 
  >> Please could tell me where I am going wrong with this?  I just
  >> can't get the source block to put a result in the table.
  [etc]

  > Hi Miles,

  > To force the value of "236:30:00" to be interpreted as a string
  > (rather than have sbe try to convert it to a number prefix the
  > reference with a "$" character).  However even doing this your
  > example exposed a bug in this sbe functionality to which I've just
  > pushed up a fix.  With the latest version of Org-mode the attached
  > works as expected.


  > #+name: workingDays #+BEGIN_SRC emacs-lisp :var hms="0" (require
  > 'org-timer) (/ (org-timer-hms-to-secs hms) (* 60 60 8)) #+END_SRC

  > Note the variable reference is prefixed with a "$" to ensure that it
  > is interpreted as a string.  See the `sbe' documentation for full
  > `sbe' usage information.

  > -- Eric Schulte http://cs.unm.edu/~eschulte/

Thanks Eryk that solves the problem!  I actually did try with an extra
"$" but it didn't work so I assumed that I had misunderstood the
documentation.  Reading the documentation again, I think it could be
improved, perhaps

#+begin_quote
to force interpretation of a cell's value as a string, prefix the
identifier with two "$"s rather than a single "$"
#+end_quote

instead of

#+begin_quote
to force interpretation of a cell's value as a string, prefix the
identifier with another "$", (e.g. @2$2 becomes $@2$2)
#+end_quote

Thanks again,

Myles

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

* Re: what's wrong with this sbe?
  2012-03-05 17:09   ` Myles English
@ 2012-03-05 17:17     ` Myles English
  2012-03-05 17:46     ` Eric Schulte
  1 sibling, 0 replies; 7+ messages in thread
From: Myles English @ 2012-03-05 17:17 UTC (permalink / raw)
  To: Eric Schulte, emacs-orgmode Mode

>> On Mon, 05 Mar 2012 17:09:48 +0000, Myles English said:

>> On Mon, 05 Mar 2012 07:34:49 -0700, Eric Schulte said:

  >> Myles English <mylesenglish@gmail.com> writes:
  >>> Hi,
  >>> 
  >>> Please could tell me where I am going wrong with this?  I just
  >>> can't get the source block to put a result in the table.
  >   [etc]

  >> Hi Miles,

  >> To force the value of "236:30:00" to be interpreted as a string
  >> (rather than have sbe try to convert it to a number prefix the
  >> reference with a "$" character).  However even doing this your
  >> example exposed a bug in this sbe functionality to which I've just
  >> pushed up a fix.  With the latest version of Org-mode the attached
  >> works as expected.


  >> #+name: workingDays #+BEGIN_SRC emacs-lisp :var hms="0" (require
  >> 'org-timer) (/ (org-timer-hms-to-secs hms) (* 60 60 8)) #+END_SRC

  >> Note the variable reference is prefixed with a "$" to ensure that
  >> it is interpreted as a string.  See the `sbe' documentation for
  >> full `sbe' usage information.

  >> -- Eric Schulte http://cs.unm.edu/~eschulte/

  > Thanks Eryk that solves the problem!  I actually did try with an
  > extra "$" but it didn't work so I assumed that I had misunderstood
  > the documentation.  Reading the documentation again, I think it
  > could be improved, perhaps

Yeah, I got these two blocks the wrong way around:

  > #+begin_quote to force interpretation of a cell's value as a string,
  > prefix the identifier with two "$"s rather than a single
  > "$" #+end_quote

  > instead of

  > #+begin_quote to force interpretation of a cell's value as a string,
  > prefix the identifier with another "$", (e.g. @2$2 becomes
  > $@2$2) #+end_quote

  > Thanks again,

  > Myles


Myles

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

* Re: what's wrong with this sbe?
  2012-03-05 17:09   ` Myles English
  2012-03-05 17:17     ` Myles English
@ 2012-03-05 17:46     ` Eric Schulte
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Schulte @ 2012-03-05 17:46 UTC (permalink / raw)
  To: Myles English; +Cc: emacs-orgmode Mode

Myles English <mylesenglish@gmail.com> writes:

>>> On Mon, 05 Mar 2012 07:34:49 -0700, Eric Schulte said:
>
>   > Myles English <mylesenglish@gmail.com> writes:
>   >> Hi,
>   >> 
>   >> Please could tell me where I am going wrong with this?  I just
>   >> can't get the source block to put a result in the table.
>   [etc]
>
>   > Hi Miles,
>
>   > To force the value of "236:30:00" to be interpreted as a string
>   > (rather than have sbe try to convert it to a number prefix the
>   > reference with a "$" character).  However even doing this your
>   > example exposed a bug in this sbe functionality to which I've just
>   > pushed up a fix.  With the latest version of Org-mode the attached
>   > works as expected.
>
>
>   > #+name: workingDays #+BEGIN_SRC emacs-lisp :var hms="0" (require
>   > 'org-timer) (/ (org-timer-hms-to-secs hms) (* 60 60 8)) #+END_SRC
>
>   > Note the variable reference is prefixed with a "$" to ensure that it
>   > is interpreted as a string.  See the `sbe' documentation for full
>   > `sbe' usage information.
>
>   > -- Eric Schulte http://cs.unm.edu/~eschulte/
>
> Thanks Eryk that solves the problem!  I actually did try with an extra
> "$" but it didn't work so I assumed that I had misunderstood the
> documentation.  Reading the documentation again, I think it could be
> improved, perhaps
>
> #+begin_quote
> to force interpretation of a cell's value as a string, prefix the
> identifier with two "$"s rather than a single "$"
> #+end_quote
>
> instead of
>
> #+begin_quote
> to force interpretation of a cell's value as a string, prefix the
> identifier with another "$", (e.g. @2$2 becomes $@2$2)
> #+end_quote
>
> Thanks again,
>

Good idea, I've just pushed up a documentation improvement.

Thanks,

>
> Myles

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

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

end of thread, other threads:[~2012-03-05 17:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-05 12:51 what's wrong with this sbe? Myles English
2012-03-05 14:09 ` Sebastien Vauban
2012-03-05 15:29   ` Myles English
2012-03-05 14:34 ` Eric Schulte
2012-03-05 17:09   ` Myles English
2012-03-05 17:17     ` Myles English
2012-03-05 17:46     ` Eric Schulte

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).