ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Lua-loop inside MetaPost
@ 2010-03-09 14:17 Andreas Harder
  2010-03-09 14:24 ` Wolfgang Schuster
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Harder @ 2010-03-09 14:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi all,

I can't find a solution for the following example:

\starttext

\startMPpage
  draw origin for i=0 step 10 until 100 : ..{down}(i,0) endfor ;
\stopMPpage

\startluacode
context.startMPpage()
  context("draw origin"..for i=0,100,10 do.."..{down}("..i..",0)"..end..";")
context.stopMPpage()
\stopluacode

\stoptext

Can someone help?

Thanks in advance
	Andreas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua-loop inside MetaPost
  2010-03-09 14:17 Lua-loop inside MetaPost Andreas Harder
@ 2010-03-09 14:24 ` Wolfgang Schuster
  2010-03-09 14:48   ` Andreas Harder
  2010-03-09 14:59   ` Hans Hagen
  0 siblings, 2 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2010-03-09 14:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Am 09.03.10 15:17, schrieb Andreas Harder:
> Hi all,
>
> I can't find a solution for the following example:
>
> \starttext
>
> \startMPpage
>    draw origin for i=0 step 10 until 100 : ..{down}(i,0) endfor ;
> \stopMPpage
>
> \startluacode
> context.startMPpage()
>    context("draw origin"..for i=0,100,10 do.."..{down}("..i..",0)"..end..";")
> context.stopMPpage()
> \stopluacode
>
> \stoptext
>
> Can someone help?
>    
\startluacode
context.startMPpage()
   context("draw origin")
   for i=0,100,10 do
     context(string.format("..{down}(%d,0)",i))
   end
   context(";")
context.stopMPpage()
\stopluacode

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua-loop inside MetaPost
  2010-03-09 14:24 ` Wolfgang Schuster
@ 2010-03-09 14:48   ` Andreas Harder
  2010-03-09 14:59   ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Harder @ 2010-03-09 14:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 774 bytes --]


Am 09.03.2010 um 15:24 schrieb Wolfgang Schuster:

> Am 09.03.10 15:17, schrieb Andreas Harder:
>> Hi all,
>> 
>> I can't find a solution for the following example:
>> 
>> \starttext
>> 
>> \startMPpage
>>   draw origin for i=0 step 10 until 100 : ..{down}(i,0) endfor ;
>> \stopMPpage
>> 
>> \startluacode
>> context.startMPpage()
>>   context("draw origin"..for i=0,100,10 do.."..{down}("..i..",0)"..end..";")
>> context.stopMPpage()
>> \stopluacode
>> 
>> \stoptext
>> 
>> Can someone help?
>>   
> \startluacode
> context.startMPpage()
>  context("draw origin")
>  for i=0,100,10 do
>    context(string.format("..{down}(%d,0)",i))
>  end
>  context(";")
> context.stopMPpage()
> \stopluacode

Thank you Wolfgang!

Greetings
	Andreas

[-- Attachment #1.2: Type: text/html, Size: 2021 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Lua-loop inside MetaPost
  2010-03-09 14:24 ` Wolfgang Schuster
  2010-03-09 14:48   ` Andreas Harder
@ 2010-03-09 14:59   ` Hans Hagen
  2010-03-09 15:11     ` Andreas Harder
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2010-03-09 14:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 9-3-2010 15:24, Wolfgang Schuster wrote:
> Am 09.03.10 15:17, schrieb Andreas Harder:
>> Hi all,
>>
>> I can't find a solution for the following example:
>>
>> \starttext
>>
>> \startMPpage
>> draw origin for i=0 step 10 until 100 : ..{down}(i,0) endfor ;
>> \stopMPpage
>>
>> \startluacode
>> context.startMPpage()
>> context("draw origin"..for i=0,100,10
>> do.."..{down}("..i..",0)"..end..";")
>> context.stopMPpage()
>> \stopluacode
>>
>> \stoptext
>>
>> Can someone help?
> \startluacode
> context.startMPpage()
> context("draw origin")
> for i=0,100,10 do
> context(string.format("..{down}(%d,0)",i))
> end
> context(";")
> context.stopMPpage()
> \stopluacode

also, if you want it in pure lua, you can put:

context.startMPpage()
   context("draw origin")
   for i=0,100,10 do
     context(string.format("..{down}(%d,0)",i))
   end
   context(";")
context.stopMPpage()

in demo.cld and then run

   context demo.cld

and the following also works:

context.startMPpage()
   context("draw origin")
   for i=0,100,10 do
     context("..{down}(%d,0)",i)
   end
   context(";")
context.stopMPpage()

that is: format is built in

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua-loop inside MetaPost
  2010-03-09 14:59   ` Hans Hagen
@ 2010-03-09 15:11     ` Andreas Harder
  2010-03-09 15:25       ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Harder @ 2010-03-09 15:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.03.2010 um 15:59 schrieb Hans Hagen:

> On 9-3-2010 15:24, Wolfgang Schuster wrote:
>> Am 09.03.10 15:17, schrieb Andreas Harder:
>>> Hi all,
>>> 
>>> I can't find a solution for the following example:
>>> 
>>> \starttext
>>> 
>>> \startMPpage
>>> draw origin for i=0 step 10 until 100 : ..{down}(i,0) endfor ;
>>> \stopMPpage
>>> 
>>> \startluacode
>>> context.startMPpage()
>>> context("draw origin"..for i=0,100,10
>>> do.."..{down}("..i..",0)"..end..";")
>>> context.stopMPpage()
>>> \stopluacode
>>> 
>>> \stoptext
>>> 
>>> Can someone help?
>> \startluacode
>> context.startMPpage()
>> context("draw origin")
>> for i=0,100,10 do
>> context(string.format("..{down}(%d,0)",i))
>> end
>> context(";")
>> context.stopMPpage()
>> \stopluacode
> 
> also, if you want it in pure lua, you can put:
> 
> context.startMPpage()
>  context("draw origin")
>  for i=0,100,10 do
>    context(string.format("..{down}(%d,0)",i))
>  end
>  context(";")
> context.stopMPpage()
> 
> in demo.cld and then run
> 
>  context demo.cld
> 
> and the following also works:
> 
> context.startMPpage()
>  context("draw origin")
>  for i=0,100,10 do
>    context("..{down}(%d,0)",i)
>  end
>  context(";")
> context.stopMPpage()
> 
> that is: format is built in

Thanks for further explanations. The following works too:

\startluacode
context.startMPpage()
  context("draw origin")
  for i=0,100,10 do
    context("..{down}("..i..",0)") – without %d
  end
  context(";")
context.stopMPpage()
\stopluacode

Or is this deprecated?

Greetings
	Andreas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Lua-loop inside MetaPost
  2010-03-09 15:11     ` Andreas Harder
@ 2010-03-09 15:25       ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2010-03-09 15:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 9-3-2010 16:11, Andreas Harder wrote:

>      context("..{down}("..i..",0)") – without %d
>
> Or is this deprecated?

no, it's just lua sttring concatination ... it all depends on taste

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2010-03-09 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-09 14:17 Lua-loop inside MetaPost Andreas Harder
2010-03-09 14:24 ` Wolfgang Schuster
2010-03-09 14:48   ` Andreas Harder
2010-03-09 14:59   ` Hans Hagen
2010-03-09 15:11     ` Andreas Harder
2010-03-09 15:25       ` Hans Hagen

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 NNTP newsgroup(s).