Re: [O] [Babel] size limit of #+call

2012-03-24 Thread Martin Halder
Am 24.03.2012 um 20:00 schrieb Nick Dokos:

> Martin Halder  wrote:
> 
>> Hi all,
>> 
>> trying to use a function to output a latex file using python with =
>> #+call.
>> 
>> The example below does work but when pycalltest gets too big it just =
>> output "nil".
>> When I call pycalltest directly with C-c C-c it works even with a big =
>> function.
>> 
>> Is there a size limit when I use #+call ?
>> 
>> Thanks for help,
>> Martin
>> 
>> #+name: =
>> pycalltest(trans=3Dtranslation,items=3Ditems,cust=3Dcustomer,deta=3Ddetail=
>> s,lang=3D"german",cur=3D"chf")
>> #+begin_src python :results output
>> execfile('latex.py')
>> print lx_config
>> #+end_src
>> #+call: pycalltest(translation,items,customer,details,"german","chf") =
>> :file "test.tex"
> 
> Can you please provide all the pieces needed to run this? I presume at least
> latex.py is needed - anything else?


ok, found with options hlines and colnames I get the same result for direct 
evaluation
and call. Problem solved, thanks and sorry for the noise.

Martin

** input table translation
#+tblname: transl
| field   | german  | english |
|-+-+-|
| country | Schweiz | Switzerland |
#+name: pycalltest(trans=transl)
#+begin_src python :results output :hlines yes :colnames no
print trans
#+end_src
#+call: pycalltest(transl) :file "test.tex"





Re: [O] [Babel] size limit of #+call

2012-03-24 Thread Martin Halder

Am 24.03.2012 um 20:00 schrieb Nick Dokos:

> Martin Halder  wrote:
> 
>> Hi all,
>> 
>> trying to use a function to output a latex file using python with =
>> #+call.
>> 
>> The example below does work but when pycalltest gets too big it just =
>> output "nil".
>> When I call pycalltest directly with C-c C-c it works even with a big =
>> function.
>> 
>> Is there a size limit when I use #+call ?
>> 
>> Thanks for help,
>> Martin
>> 
>> #+name: =
>> pycalltest(trans=3Dtranslation,items=3Ditems,cust=3Dcustomer,deta=3Ddetail=
>> s,lang=3D"german",cur=3D"chf")
>> #+begin_src python :results output
>> execfile('latex.py')
>> print lx_config
>> #+end_src
>> #+call: pycalltest(translation,items,customer,details,"german","chf") =
>> :file "test.tex"
> 
> Can you please provide all the pieces needed to run this? I presume at least
> latex.py is needed - anything else?

could reduce the problem to a small example, seems the table is handled 
differently when using #+call.

direct evaluation:
[['country', 'Schweiz', 'Switzerland']]

using call:
[['field', 'german', 'english'], None, ['country', 'Schweiz', 'Switzerland']]

#+tblname: transl
| field   | german  | english |
|-+-+-|
| country | Schweiz | Switzerland |

#+name: pycalltest(trans=transl)
#+begin_src python :results output
print trans
#+end_src

#+call: pycalltest(transl) :file "test.tex"



[O] [Babel] size limit of #+call

2012-03-24 Thread Martin Halder
Hi all,

trying to use a function to output a latex file using python with #+call.

The example below does work but when pycalltest gets too big it just output 
"nil".
When I call pycalltest directly with C-c C-c it works even with a big function.

Is there a size limit when I use #+call ?

Thanks for help,
Martin

#+name: 
pycalltest(trans=translation,items=items,cust=customer,deta=details,lang="german",cur="chf")
#+begin_src python :results output
execfile('latex.py')
print lx_config
#+end_src

#+call: pycalltest(translation,items,customer,details,"german","chf") :file 
"test.tex"




Re: [O] table spreadsheet problem

2012-03-19 Thread Martin Halder

Am 19.03.2012 um 16:56 schrieb Nick Dokos:

> Russell Adams  wrote:
> 
>> On Mon, Mar 19, 2012 at 04:01:42PM +0100, Martin Halder wrote:
>>> Hi all,
>>> 
>>> question about table calculation. Found in the documentation that I could 
>>> refer to e.g. first line after second hline with @II+2.
>>> 
>>> Would like to calculate sum = vsum(@I..@II) and tax = sum * 0.08
>>> 
>>> Am I doing sth wrong ?
>>> 
>>> Thanks for help,
>>> Martin
>>> 
>>> | article |  price |
>>> |-+|
>>> | item1   | 100.00 |
>>> | item2   | 200.00 |
>>> |-+|
>>> | sum ||
>>> | tax ||
>>> |-+|
>>> | sum |  0 |
>>> #+TBLFM: 
>>> @II+1$2=vsum(@I..@II);f2N::@II+2$2=@II+1$2*0.08;f2N::@>$2=vsum(@II..@III);f2N
>>> 
>>> 
>> 
>> | article |  price |
>> |-+|
>> | item1   | 100.00 |
>> | item2   | 200.00 |
>> |-+|
>> | sum | 300.00 |
>> | tax |  24.00 |
>> |-+|
>> | sum | 324.00 |
>> #+TBLFM: 
>> @4$2=vsum(@-I..@-II);%.2f::@5$2=@4$2*0.08;%.2f::@6$2=vsum(@-I..@-II);%.2f
>> 
>> I often use negative headline references for total lines in order to
>> sum backward from the current cell.
>> 
>> So vsum(@-I..@-II);%.2f means sum the cells between the first headline
>> above the current cell to the second headline above the current cell,
>> and then format the result as a decimal with two decimal places
>> (%.2f).
>> 
>> Looking at your formula, I think you manually wrote the TBLFM
>> line. One thing I've found is that the TBLFM line doesn't support
>> relative references for the cell specification, only in the formula.
>> 
>> I used C-u C-c = to set mine.
>> 
> 
> Nowadays, you can use (both on the LHS and the RHS of the formula)
> symbolic references relative to the first, second, third ... row like
> this: @<, @<<, @<< ... and relative to the last, penultimate,
> antepenultimate (is there such a word?) row like this: @>, @>>, @>>>
> ..., and similarly for columns, so you could write the formula, like
> this:
> 
> #+TBLFM: 
> @>>>$>=vsum(@-I..@-II);%.2f::@>>$>=@>>>$>*0.08;%.2f::@>$>=vsum(@-I..@-II);%.2f
> 
> This *does* require iterated evaluations, so C-u C-u C-c C-c is your
> best bet, to make sure everything is updated properly.
> 
> Nick
> 
that is fantastic, many thanks for you help to you both.
Martin

>> Good luck!
>> 
>> --
>> Russell Adamsrlad...@adamsinfoserv.com
>> 
>> PGP Key ID: 0x1160DCB3   http://www.adamsinfoserv.com/
>> 
>> Fingerprint:1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3
>> 
> 




Re: [O] table spreadsheet problem

2012-03-19 Thread Martin Halder

Am 19.03.2012 um 16:32 schrieb Russell Adams:

> On Mon, Mar 19, 2012 at 04:01:42PM +0100, Martin Halder wrote:
>> Hi all,
>> 
>> question about table calculation. Found in the documentation that I could 
>> refer to e.g. first line after second hline with @II+2.
>> 
>> Would like to calculate sum = vsum(@I..@II) and tax = sum * 0.08
>> 
>> Am I doing sth wrong ?
>> 
>> Thanks for help,
>> Martin
>> 
>> | article |  price |
>> |-+|
>> | item1   | 100.00 |
>> | item2   | 200.00 |
>> |-+|
>> | sum ||
>> | tax ||
>> |-+|
>> | sum |  0 |
>> #+TBLFM: 
>> @II+1$2=vsum(@I..@II);f2N::@II+2$2=@II+1$2*0.08;f2N::@>$2=vsum(@II..@III);f2N
>> 
>> 
> 
> | article |  price |
> |-+|
> | item1   | 100.00 |
> | item2   | 200.00 |
> |-+|
> | sum | 300.00 |
> | tax |  24.00 |
> |-+|
> | sum | 324.00 |
> #+TBLFM: 
> @4$2=vsum(@-I..@-II);%.2f::@5$2=@4$2*0.08;%.2f::@6$2=vsum(@-I..@-II);%.2f
> 
> I often use negative headline references for total lines in order to
> sum backward from the current cell.
> 
> So vsum(@-I..@-II);%.2f means sum the cells between the first headline
> above the current cell to the second headline above the current cell,
> and then format the result as a decimal with two decimal places
> (%.2f).
> 
> Looking at your formula, I think you manually wrote the TBLFM
> line. One thing I've found is that the TBLFM line doesn't support
> relative references for the cell specification, only in the formula.
> 
> I used C-u C-c = to set mine.
> 
> Good luck!
> 
Hi Russell,

right, I wrote it manually. Thanks for your formula, the problem I have is that 
there
could be an "item 3" and therefore the "sum", "tax" and second "sum" lines are 
not fixed.
Is there a solution to specify them dynamically or do I have to modify the 
position
every time I enter a new item ?

Thanks,
Martin

> --
> Russell Adamsrlad...@adamsinfoserv.com
> 
> PGP Key ID: 0x1160DCB3   http://www.adamsinfoserv.com/
> 
> Fingerprint:1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3
> 




[O] table spreadsheet problem

2012-03-19 Thread Martin Halder
Hi all,

question about table calculation. Found in the documentation that I could refer 
to e.g. first line after second hline with @II+2.

Would like to calculate sum = vsum(@I..@II) and tax = sum * 0.08

Am I doing sth wrong ?

Thanks for help,
Martin

| article |  price |
|-+|
| item1   | 100.00 |
| item2   | 200.00 |
|-+|
| sum ||
| tax ||
|-+|
| sum |  0 |
#+TBLFM: 
@II+1$2=vsum(@I..@II);f2N::@II+2$2=@II+1$2*0.08;f2N::@>$2=vsum(@II..@III);f2N




Re: [O] table as parameter for latex block

2012-03-18 Thread Martin Halder
> Martin Halder  writes:
> 
>>> Martin Halder  writes:
>>> 
>>>> Hi all,
>>>> 
>>>> was trying to use a table as input for a latex block. Is there a way to 
>>>> directly reference parts of the table inside the block or do I have to 
>>>> specify each parameter as separate parameter ?
>>>> 
>>>> Thanks for help,
>>>> Martin
>>> Aloha Martin,
>>> 
>>> Can I ask why you want to use a table as input for a latex block?  An
>>> alternative is to send the table to a source block in some other
>>> language and then evaluate with :results latex.  The advantage is that
>>> the other language can have loops and complex data types that make it
>>> relatively easy to deal with tables.  It might be possible to do these
>>> kinds of things with TeX, but it is likely to be difficult.
>>> 
>>> hth,
>>> Tom
>> 
>> Aloha Tom,
>> 
>> the reason was that I have a quite complex latex file in a src latex block 
>> (which I tangle)
>> and just wanted to replace some variables from a table.
>> 
>> But :results latex looks very interesting, will have a look if I can solve 
>> it with that one,
>> many thanks for the hint.
>> 
>> This is my use case, the example below was maybe too much simplified:
>> 
>> #begin_src latex
>> ... weird latex code
>>  \put(-2,-50){
>>  \parbox{8cm}{
>>  \tiny{mycompany - mystree - mycountry}\\ \\
>>  \normalsize
>>  \textbf{company}\\
>>  street\\
>>  \textbf{country}
>>  \vspace{2mm}\\
>>  }
>>  }
>> ... weird latex code
>> #end_src latex
> 
> Aloha Martin,
> 
> Here is the basic idea in pseudo python.  
> 
> #begin_src python :results output latex
> ... weird latex code
> s = '''   \\put(-2,-50){
>   \\parbox{8cm}{
>   \\tiny{%s - %s - %s} 
>   \\normalsize
>   \\textbf{%s}
>   street
>   \\textbf{%s}
>   \\vspace{2mm}
>   }
>   }''' % (mycompany, mystree, mycountry, company, country)
> print s
> ... weird latex code
> #end_src python
> 
> hth,
> Tom

Aloha Tom,

great, thanks. This one is working. Did not think about sending the whole file 
through python.

Cheers,
Martin

>> 
>> Cheers,
>> Martin
>> 
>>> 
>>>> 
>>>> This is working:
>>>> 
>>>> #+tblname: data
>>>> | Name| John Doe |
>>>> | Address | Doestreet 42 |
>>>> | Country | Doecountry   |
>>>> 
>>>> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
>>>> #+begin_src latex
>>>> name
>>>> address
>>>> country
>>>> #+end_src
>>>> 
>>>> #+RESULTS: invoice
>>>> #+BEGIN_LaTeX
>>>> John Doe
>>>> Doestreet 42
>>>> Doecountry
>>>> #+END_LaTeX
>>>> 
>>>> what I would like to do:
>>>> 
>>>> #+name: invoice(data=data)
>>>> #+begin_src latex
>>>> data[0,1]
>>>> data[1,1]
>>>> data[2,1]
>>>> #+end_src
>>>> 
>>>> or even better:
>>>> 
>>>> #+name: invoice(data=data)
>>>> #+begin_src latex
>>>> data['Name']
>>>> data['Adress']
>>>> data['Country']
>>>> #+end_src
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> -- 
>>> Thomas S. Dye
>>> http://www.tsdye.com
>> 
> 
> -- 
> T.S. Dye & Colleagues, Archaeologists
> 735 Bishop St, Suite 315, Honolulu, HI 96813
> Tel: 808-529-0866, Fax: 808-529-0884
> http://www.tsdye.com




Re: [O] table as parameter for latex block

2012-03-18 Thread Martin Halder

> Martin Halder  writes:
> 
>> Hi all,
>> 
>> was trying to use a table as input for a latex block. Is there a way to 
>> directly reference parts of the table inside the block or do I have to 
>> specify each parameter as separate parameter ?
>> 
>> Thanks for help,
>> Martin
> Aloha Martin,
> 
> Can I ask why you want to use a table as input for a latex block?  An
> alternative is to send the table to a source block in some other
> language and then evaluate with :results latex.  The advantage is that
> the other language can have loops and complex data types that make it
> relatively easy to deal with tables.  It might be possible to do these
> kinds of things with TeX, but it is likely to be difficult.
> 
> hth,
> Tom

Aloha Tom,

the reason was that I have a quite complex latex file in a src latex block 
(which I tangle)
and just wanted to replace some variables from a table.

But :results latex looks very interesting, will have a look if I can solve it 
with that one,
many thanks for the hint.

This is my use case, the example below was maybe too much simplified:

#begin_src latex
... weird latex code
\put(-2,-50){
\parbox{8cm}{
\tiny{mycompany - mystree - mycountry}\\ \\
\normalsize
\textbf{company}\\
street\\
\textbf{country}
\vspace{2mm}\\
}
}
... weird latex code
#end_src latex

Cheers,
Martin

> 
>> 
>> This is working:
>> 
>> #+tblname: data
>> | Name| John Doe |
>> | Address | Doestreet 42 |
>> | Country | Doecountry   |
>> 
>> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
>> #+begin_src latex
>> name
>> address
>> country
>> #+end_src
>> 
>> #+RESULTS: invoice
>> #+BEGIN_LaTeX
>> John Doe
>> Doestreet 42
>> Doecountry
>> #+END_LaTeX
>> 
>> what I would like to do:
>> 
>> #+name: invoice(data=data)
>> #+begin_src latex
>> data[0,1]
>> data[1,1]
>> data[2,1]
>> #+end_src
>> 
>> or even better:
>> 
>> #+name: invoice(data=data)
>> #+begin_src latex
>> data['Name']
>> data['Adress']
>> data['Country']
>> #+end_src
>> 
>> 
>> 
>> 
> 
> -- 
> Thomas S. Dye
> http://www.tsdye.com




[O] table as parameter for latex block

2012-03-18 Thread Martin Halder
Hi all,

was trying to use a table as input for a latex block. Is there a way to 
directly reference parts of the table inside the block or do I have to specify 
each parameter as separate parameter ?

Thanks for help,
Martin

This is working:

#+tblname: data
| Name| John Doe |
| Address | Doestreet 42 |
| Country | Doecountry   |

#+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
#+begin_src latex
name
address
country
#+end_src

#+RESULTS: invoice
#+BEGIN_LaTeX
John Doe
Doestreet 42
Doecountry
#+END_LaTeX

what I would like to do:

#+name: invoice(data=data)
#+begin_src latex
data[0,1]
data[1,1]
data[2,1]
#+end_src

or even better:

#+name: invoice(data=data)
#+begin_src latex
data['Name']
data['Adress']
data['Country']
#+end_src





Re: [O] org table calc and lisp for hh:mm timetable

2011-03-24 Thread Martin Halder
>> If we're not just looking for a neat workaround for some special cases 
>> anymore, but looking at making org-tables aware of time-like strings 
>> by default, a better strategy than to convert them into integers might 
>> be to translate them into Calc time format and back again.
>> 
>> After all, Calc and hence the Org spreadsheet already handles time 
>> arithmetic perfectly well, it's just that it would be nice to have 
>> this functionality with the extra option to enter and display times as 
>> =12:45= rather than =12@ 45'= or =12h 45m=.
>> 
> 
> I did not realize that calc (and hence Org) already supported operating
> on time values.  The =7@ 30'= format does indeed work well for time
> table formulas (although the =12h 5m= format does not), e.g.,
> 
> | 1@ 20' | 2 | 0@ 40' 0."  |
> | 2@ 5'  | 3 | 0@ 41' 40." |
> #+TBLFM: $3=$1/$2
> 
> Maybe all that is needed is explicit mention of this syntax somewhere in
> the table section of the Org-mode manual.
> 
> The only remaining reason to support a %d:%d time format is that it is
> what I (and I expect most users) would first think of to represent time,
> and supporting such a format would allow time calculation in a table to
> "just work" -- meaning users could likely manipulate time without having
> to first look in the manual for the appropriate Calc format.
> 
> However as Carsten mentioned such an automatic translation of e.g.,
> =7:20= to =7@ 20'= would be a bit bold, and (as mentioned elsewhere) it
> would result in having to make some denomination decisions, namely does
> =7:20= convert to =7@ 20'= or =7' 20"=.
> 
> For now I've posted my `with-time' macro up to Worg.
> 
> Cheers -- Eric

Hi all,

just came back on this thread and was amazed what you guys did with it.. 
amazing.. havent tried the patch yet but the with-time macro is great. Now it 
is even easy to sum up a whole column of timevalues.

I use it like the following now:

| start | lunch |  back | leave |   sum |
|---+---+---+---+---|
|  8:00 | 12:00 | 13:00 | 17:00 |  8:00 |
|  8:00 | 12:00 | 13:00 | 17:00 |  8:00 |
|---+---+---+---+---|
|   |   |   |   | 16:00 |
#+TBLFM: @>$5='(with-time t (+ @2..@>>))

Thanks a lot (also for making it to org hacks : )
Martin




[O] error in tableformula or bug

2011-03-24 Thread Martin Halder
Hi again,

have traced it down to the following commit which introduces the problem 
(thanks to bisect):
[3dd474575205d3808390fc6ea2d5feccdb3d4305] Tables:  Make @< and $< point to 
row/column 1 in a stable way

Was there a change in the format or is it really a bug ?

Thanks for help,
Martin

> found some strange behavior which was working before as far as I remember.. I 
> am on commit 078c01b.
> 
> this is working correctly:
> | 10 |
> | 10 |
> | 20 |
> ||
> | 40 |
> #+TBLFM: @>$1=vsum(@1..@3)
> 
> this one with relative indexing (@>-1) not: (value is changing every time the 
> formula is applied: 37, 73, 109 (+36 every time)
> | 10 |
> | 10 |
> | 20 |
> ||
> | 37 |
> #+TBLFM: @>$1=vsum(@1..@>-1)





[O] error in tableformula or bug

2011-03-23 Thread Martin Halder
Hi all,

found some strange behavior which was working before as far as I remember.. I 
am on commit 078c01b.

this is working correctly:
| 10 |
| 10 |
| 20 |
||
| 40 |
#+TBLFM: @>$1=vsum(@1..@3)

this one with relative indexing (@>-1) not: (value is changing every time the 
formula is applied: 37, 73, 109 (+36 every time)
| 10 |
| 10 |
| 20 |
||
| 37 |
#+TBLFM: @>$1=vsum(@1..@>-1)

Thanks for help,
Martin




Re: [O] org table calc and lisp for hh:mm timetable

2011-03-16 Thread Martin Halder
Hi Christian,

this is fantastic, already love lisp, thanks a lot.. now I have exactly what I 
wanted.. additionally I needed the time format in industrial mode (1h = 100m = 
100s), implemented in ihms.

Thanks,
Martin

| Date | Start | Lunch |  Back |   End |  Sum |  Ind |
|--+---+---+---+---+--+--|
| [2011-03-01 Tue] |  8:00 | 12:00 | 12:30 | 18:15 | 9:45 | 9.75 |
#+TBLFM: $6='(hms (+ (- (sec $5) (sec $4)) (- (sec $3) (sec $2::$7='(ihms 
(+ (- (sec $5) (sec $4)) (- (sec $3) (sec $2

(defun sec (arg)
  (if (string-match org-timer-re arg)
  (org-timer-hms-to-secs arg)
(org-timer-hms-to-secs (concat arg ":00"

(defun hms (s)
  (let (m h)
(setq s (abs s)
  m (/ s 60) s (- s (* 60 m))
  h (/ m 60) m (- m (* 60 h)))
(format "%d:%02d" h m)))

(defun ihms (s)
  (let (m h)
(setq s (/ (* s 1) 3600)
  s (abs s)
  m (/ s 100) s (- s (* 100 m))
  h (/ m 100) m (- m (* 100 h)))
(format "%d.%02d" h m)))

Am 15.03.2011 um 22:47 schrieb Christian Moe:

> Hi,
> 
> This is ingenious! But I have a different solution that borrows conversion 
> functions from org-timer.el.
> 
> To avoid an insanely long formula, I'll alias those functions with shorter 
> names which don't seem to colide with anything in my Emacs.
> 
> #+begin_src emacs-lisp
>  (defun sec (arg)
>(org-timer-hms-to-secs arg))
> 
>  (defun hms (arg)
>(org-timer-secs-to-hms arg))
> #+end_src
> 
> Now, just do this:
> 
> |Start |Lunch | Back |  End |  Sum|
> |--+--+--+--+-|
> | 08:00:00 | 12:20:00 | 13:00:00 | 17:00:00 | 8:20:00 |
> #+TBLFM: $5='(hms (+ (- (sec $4) (sec $3)) (- (sec $2) (sec $1
> 
> This already works for me, because my main interest here is in keeping track 
> of my jogging, but those seconds are spurious precision for your use case, 
> and take up space. So rewrite sec and hms:
> 
> #+begin_src emacs-lisp
>  (defun sec (arg)
>(if (string-match org-timer-re arg)
>(org-timer-hms-to-secs arg)
>  (org-timer-hms-to-secs (concat arg ":00"
> 
>  (defun hms (arg)
>(if (integerp (/ arg 60))
>(substring (org-timer-secs-to-hms arg) 0 -3)
>  (org-timer-secs-to-hms arg)))
> #+end_src
> 
> Now sec will correctly convert hh:mm stamps, too, and hms will convert to 
> hh:mm format if the argument is in whole minutes, otherwise to hh:mm:ss. So:
> 
> | Start | Lunch |  Back |   End |  Sum |
> |---+---+---+---+--|
> | 08:00 | 12:20 | 13:00 | 17:00 | 8:20 |
> #+TBLFM: $5='(hms (+ (- (sec $4) (sec $3)) (- (sec $2) (sec $1



Re: [O] org table calc and lisp for hh:mm timetable

2011-03-15 Thread Martin Halder

>> I was trying to generate a simple table with time format "hh:mm" and
>> auto calculate daily sum.. clocking working time was too much so I
>> thought this would be easy but ended up with the following.. it works
>> but is not beautiful (apply formula twice and same information
>> multiple times) and I would like to get rid of the "hms", "hh" and
>> "mm" columns and therefore call "hmconcat" directly somehow.. Any help
>> is highly appreciated..
>> 
>> Thanks,
>> Martin
>> 
>> | Date | Start | Lunch |  Back |   End |   Sum | hms   | hh 
>> | mm |
>> |--+---+---+---+---+---+---++|
>> | [2011-03-01 Tue] | 08:00 | 12:20 | 13:00 | 17:00 | 08:20 | 8@ 20' 0" |  8 
>> | 20 |
>> #+TBLFM: $6='(hmconcat $8 $9)::$7=time(<2010-01-01 $5>)-time(<2010-01-01 
>> $4>)+time(<2010-01-01 $3>)-time(<2010-01-01 $2>)::$8=hour($7)::$9=minute($7)
>> 
>> (defun hmconcat (hh mm) (interactive)
>>(if (> (length hh) 1)
>>(setq temp (concat hh ":")) (setq temp (concat "0" hh ":")))
>>(if (> (length mm) 1)
>>(concat temp mm) (concat temp "0" mm)))
> 
> Martin,
> 
> glad to see you got further with this!
> 
> You can definitely get rid of hmconcat by using a combination of
> string-to-number and format (and I'm sure it's possible to get this done
> with simpler elisp):
> 
> --8<---cut here---start->8---
> 
> | Date | Start | Lunch |  Back |   End |   Sum | hms   | hh | 
> mm |
> |--+---+---+---+---+---+---++|
> | [2011-03-01 Tue] | 08:00 | 12:20 | 13:00 | 17:00 | 08:20 | 8@ 20' 0" |  8 | 
> 20 |
> #+TBLFM: $6='(format "%02d:%02d" (string-to-number $8) (string-to-number 
> $9))::$7=time(<2010-01-01 $5>)-time(<2010-01-01 $4>)+time(<2010-01-01 
> $3>)-time(<2010-01-01 $2>)::$8=hour($7)::$9=minute($7)
> --8<---cut here---end--->8---

Hi Eric,

yes and thanks for the previous help, too.. the good old printf.. I would like 
to pass the result of time() directly to a lisp function, like:
#+TBLFM: $6='(coolfunc (time(...$5)-time(...$4)))

If I would know how to pass the result, eg as a string, to a lisp function I 
could sort it out, I guess.

Thanks,
Martin


[O] org table calc and lisp for hh:mm timetable

2011-03-15 Thread Martin Halder
Hi all,

some words of warning: this was written by an Emacs, Org, Lisp and Calc 
newbie.. and congratulations on converting a vim user btw, org mode is great : )

I was trying to generate a simple table with time format "hh:mm" and auto 
calculate daily sum.. clocking working time was too much so I thought this 
would be easy but ended up with the following.. it works but is not beautiful 
(apply formula twice and same information multiple times) and I would like to 
get rid of the "hms", "hh" and "mm" columns and therefore call "hmconcat" 
directly somehow.. Any help is highly appreciated.. 

Thanks,
Martin

| Date | Start | Lunch |  Back |   End |   Sum | hms   | hh | 
mm |
|--+---+---+---+---+---+---++|
| [2011-03-01 Tue] | 08:00 | 12:20 | 13:00 | 17:00 | 08:20 | 8@ 20' 0" |  8 | 
20 |
#+TBLFM: $6='(hmconcat $8 $9)::$7=time(<2010-01-01 $5>)-time(<2010-01-01 
$4>)+time(<2010-01-01 $3>)-time(<2010-01-01 $2>)::$8=hour($7)::$9=minute($7)

(defun hmconcat (hh mm) (interactive)
(if (> (length hh) 1)
(setq temp (concat hh ":")) (setq temp (concat "0" hh ":")))
(if (> (length mm) 1)
(concat temp mm) (concat temp "0" mm)))