[O] what's wrong with this sbe?

2012-03-05 Thread Myles English

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



Re: [O] what's wrong with this sbe?

2012-03-05 Thread Sebastien Vauban
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




Re: [O] what's wrong with this sbe?

2012-03-05 Thread Myles English

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



Re: [O] what's wrong with this sbe?

2012-03-05 Thread Eric Schulte
Myles English mylesengl...@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.

#+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))

Cheers,



 Thanks,

 Myles


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


Re: [O] what's wrong with this sbe?

2012-03-05 Thread Myles English
 On Mon, 05 Mar 2012 17:09:48 +, Myles English said:

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

   Myles English mylesengl...@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



Re: [O] what's wrong with this sbe?

2012-03-05 Thread Myles English

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

   Myles English mylesengl...@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



Re: [O] what's wrong with this sbe?

2012-03-05 Thread Eric Schulte
Myles English mylesengl...@gmail.com writes:

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

Myles English mylesengl...@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/