ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* loop textext and \MPstring{…}
@ 2009-08-11 14:08 Andreas Harder
  2009-08-11 22:07 ` Hans Hagen
  2009-08-12  5:40 ` Aditya Mahajan
  0 siblings, 2 replies; 13+ messages in thread
From: Andreas Harder @ 2009-08-11 14:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I am trying to achieve the following:

\setMPtext{1}{ABC}
\setMPtext{2}{DEF}
\setMPtext{3}{GHI}

\starttext

\startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
   for i=1 upto 3:
     draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
   endfor;
\stopMPpage

\stoptext

There is no error but no content either. What's wrong?

Thanks
	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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-11 14:08 loop textext and \MPstring{…} Andreas Harder
@ 2009-08-11 22:07 ` Hans Hagen
  2009-08-12  5:40 ` Aditya Mahajan
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2009-08-11 22:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Andreas Harder wrote:
> Hi,
> 
> I am trying to achieve the following:
> 
> \setMPtext{1}{ABC}
> \setMPtext{2}{DEF}
> \setMPtext{3}{GHI}
> 
> \starttext
> 
> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>   for i=1 upto 3:
>     draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>   endfor;
> \stopMPpage
> 
> \stoptext
> 
> There is no error but no content either. What's wrong?

this won't work as {i} is not expanded at the right moment

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-11 14:08 loop textext and \MPstring{…} Andreas Harder
  2009-08-11 22:07 ` Hans Hagen
@ 2009-08-12  5:40 ` Aditya Mahajan
  2009-08-12 10:51   ` Andreas Harder
  1 sibling, 1 reply; 13+ messages in thread
From: Aditya Mahajan @ 2009-08-12  5:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 11 Aug 2009, Andreas Harder wrote:

> Hi,
>
> I am trying to achieve the following:
>
> \setMPtext{1}{ABC}
> \setMPtext{2}{DEF}
> \setMPtext{3}{GHI}
>
> \starttext
>
> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>  for i=1 upto 3:
>    draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>  endfor;
> \stopMPpage
>
> \stoptext
>
> There is no error but no content either. What's wrong?

Another way to do this is to use

\TeXtext{1}{ABC} etc.

and then call

draw sometxt(i)

For Sec 4.5 of Mojca's my way on sometxt 
http://dl.contextgarden.net/myway/sometxt.pdf

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-12  5:40 ` Aditya Mahajan
@ 2009-08-12 10:51   ` Andreas Harder
  2009-08-12 13:25     ` Aditya Mahajan
  2009-08-12 18:34     ` Mojca Miklavec
  0 siblings, 2 replies; 13+ messages in thread
From: Andreas Harder @ 2009-08-12 10:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:

> On Tue, 11 Aug 2009, Andreas Harder wrote:
>
>> Hi,
>>
>> I am trying to achieve the following:
>>
>> \setMPtext{1}{ABC}
>> \setMPtext{2}{DEF}
>> \setMPtext{3}{GHI}
>>
>> \starttext
>>
>> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>> for i=1 upto 3:
>>   draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>> endfor;
>> \stopMPpage
>>
>> \stoptext
>>
>> There is no error but no content either. What's wrong?
>
> Another way to do this is to use
>
> \TeXtext{1}{ABC} etc.
>
> and then call
>
> draw sometxt(i)
>
> For Sec 4.5 of Mojca's my way on sometxt http://dl.contextgarden.net/myway/sometxt.pdf

Thank you for the tip, I tried it, but sometext seems deprecated in  
mkiv ("[do we need TeXtexts in MkIV]").

I've different buffers named 1–12 and would like to pipe them to  
Metapost. I thought I could use a textext(\getbuffer[i])-construct, it  
failed. So I tried it with \setMPtext{}{} …

What is the approach to achieve this?

Thank you 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-12 10:51   ` Andreas Harder
@ 2009-08-12 13:25     ` Aditya Mahajan
  2009-08-12 14:53       ` Andreas Harder
  2009-08-12 19:23       ` Hans Hagen
  2009-08-12 18:34     ` Mojca Miklavec
  1 sibling, 2 replies; 13+ messages in thread
From: Aditya Mahajan @ 2009-08-12 13:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1873 bytes --]

On Wed, 12 Aug 2009, Andreas Harder wrote:

>
> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>
>> On Tue, 11 Aug 2009, Andreas Harder wrote:
>> 
>>> Hi,
>>> 
>>> I am trying to achieve the following:
>>> 
>>> \setMPtext{1}{ABC}
>>> \setMPtext{2}{DEF}
>>> \setMPtext{3}{GHI}
>>> 
>>> \starttext
>>> 
>>> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>>> for i=1 upto 3:
>>>  draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>>> endfor;
>>> \stopMPpage
>>> 
>>> \stoptext
>>> 
>>> There is no error but no content either. What's wrong?
>> 
>> Another way to do this is to use
>> 
>> \TeXtext{1}{ABC} etc.
>> 
>> and then call
>> 
>> draw sometxt(i)
>> 
>> For Sec 4.5 of Mojca's my way on sometxt 
>> http://dl.contextgarden.net/myway/sometxt.pdf
>
> Thank you for the tip, I tried it, but sometext seems deprecated in mkiv 
> ("[do we need TeXtexts in MkIV]").

I thought that you were using MKII.

> I've different buffers named 1–12 and would like to pipe them to Metapost. I 
> thought I could use a textext(\getbuffer[i])-construct, it failed. So I tried 
> it with \setMPtext{}{} …
>
> What is the approach to achieve this?

Well, if nothing else works, you can always cheat.

\startluacode
   userdata = userdata or {}
   userdata.labels = {
     [1] = "ABC" ,
     [2] = "DEF" ,
     [3] = "GHI" }

   function userdata.shift(i)
     return "(" .. i .. "cm ," .. i .. "cm )"
   end

   function userdata.draw(i)
     return "draw btex " .. userdata.labels[i] .. " etex  shifted ".. 
userdata.shift(i) .. ";"
   end

\stopluacode

\starttext

\startluacode
   context.startMPpage({offset = "1ex", width = [[\paperwidth]], height = 
[[\paperheight]]})
     for i = 1,3 do
       context(userdata.draw(i))
     end
   context.stopMPpage()
\stopluacode

\stoptext

Aditya

[-- Attachment #2: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-12 13:25     ` Aditya Mahajan
@ 2009-08-12 14:53       ` Andreas Harder
  2009-08-13  3:00         ` Aditya Mahajan
  2009-08-12 19:23       ` Hans Hagen
  1 sibling, 1 reply; 13+ messages in thread
From: Andreas Harder @ 2009-08-12 14:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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


Am 12.08.2009 um 15:25 schrieb Aditya Mahajan:

> On Wed, 12 Aug 2009, Andreas Harder wrote:
>
>>
>> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>>
>>> On Tue, 11 Aug 2009, Andreas Harder wrote:
>>>> Hi,
>>>> I am trying to achieve the following:
>>>> \setMPtext{1}{ABC}
>>>> \setMPtext{2}{DEF}
>>>> \setMPtext{3}{GHI}
>>>> \starttext
>>>> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>>>> for i=1 upto 3:
>>>> draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>>>> endfor;
>>>> \stopMPpage
>>>> \stoptext
>>>> There is no error but no content either. What's wrong?
>>> Another way to do this is to use
>>> \TeXtext{1}{ABC} etc.
>>> and then call
>>> draw sometxt(i)
>>> For Sec 4.5 of Mojca's my way on sometxt http://dl.contextgarden.net/myway/sometxt.pdf
>>
>> Thank you for the tip, I tried it, but sometext seems deprecated in  
>> mkiv ("[do we need TeXtexts in MkIV]").
>
> I thought that you were using MKII.
>
>> I've different buffers named 1–12 and would like to pipe them to  
>> Metapost. I thought I could use a textext(\getbuffer[i])-construct,  
>> it failed. So I tried it with \setMPtext{}{} …
>>
>> What is the approach to achieve this?
>
> Well, if nothing else works, you can always cheat.
>
> \startluacode
>  userdata = userdata or {}
>  userdata.labels = {
>    [1] = "ABC" ,
>    [2] = "DEF" ,
>    [3] = "GHI" }
>
>  function userdata.shift(i)
>    return "(" .. i .. "cm ," .. i .. "cm )"
>  end
>
>  function userdata.draw(i)
>    return "draw btex " .. userdata.labels[i] .. " etex  shifted "..  
> userdata.shift(i) .. ";"
>  end
>
> \stopluacode
>
> \starttext
>
> \startluacode
>  context.startMPpage({offset = "1ex", width = [[\paperwidth]],  
> height = [[\paperheight]]})
>    for i = 1,3 do
>      context(userdata.draw(i))
>    end
>  context.stopMPpage()
> \stopluacode
>
> \stoptext

Thank you, very nice.

In the "real world“ I've stripped quotes form another document and  
stored them in buffer-environments (attachment). With your solution  
I've no idea how to incorporate them in a "automatic" manner.


[-- Attachment #2: MP-random-textboxes2.tex --]
[-- Type: application/x-tex, Size: 4041 bytes --]

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



Anyhow thanks

	Andreas

[-- Attachment #4: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-12 10:51   ` Andreas Harder
  2009-08-12 13:25     ` Aditya Mahajan
@ 2009-08-12 18:34     ` Mojca Miklavec
  2009-08-12 21:22       ` Hans Hagen
  2009-08-12 21:27       ` Andreas Harder
  1 sibling, 2 replies; 13+ messages in thread
From: Mojca Miklavec @ 2009-08-12 18:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, Aug 12, 2009 at 12:51, Andreas Harder wrote:
> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>
>> Another way to do this is to use
>>
>> \TeXtext{1}{ABC} etc.
>>
>> and then call
>>
>> draw sometxt(i)
>>
>> For Sec 4.5 of Mojca's my way on sometxt
>> http://dl.contextgarden.net/myway/sometxt.pdf
>
> Thank you for the tip, I tried it, but sometext seems deprecated in mkiv
> ("[do we need TeXtexts in MkIV]").

This only means that you need to send a request to Hans and ask for
reenabling the feature, explaining that it's still usable :) :) :)
It's a question from him after all (I think that I disabled the
feature in my module for mkiv since it didn't work). If he was sure
that it needs to be deprecated, he would not write that string :)

I'm sure that there's a workaround (or at least a dozen of other
ways), but I have no time (and my computer is being repaired again) to
inspect right now.

MKIV is both very powerful and fast, so you could probably also define
strings inside metapost run, something like

string mystrings[]; strings[1] := "ABC"; strings[2] = "DEF";
draw textext(strings[1]);

Untested.

> I've different buffers named 1–12 and would like to pipe them to Metapost. I
> thought I could use a textext(\getbuffer[i])-construct, it failed. So I
> tried it with \setMPtext{}{} …

(There should be at least quotation marks: textext("\getbuffer[i]"),
but I don't clain that it would work then.)

Maybe Hans should answer why \setMPtext fails.

Mojca
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-12 13:25     ` Aditya Mahajan
  2009-08-12 14:53       ` Andreas Harder
@ 2009-08-12 19:23       ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2009-08-12 19:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Aditya Mahajan wrote:
> On Wed, 12 Aug 2009, Andreas Harder wrote:
> 
>>
>> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>>
>>> On Tue, 11 Aug 2009, Andreas Harder wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to achieve the following:
>>>>
>>>> \setMPtext{1}{ABC}
>>>> \setMPtext{2}{DEF}
>>>> \setMPtext{3}{GHI}
>>>>
>>>> \starttext
>>>>
>>>> \startMPpage[offset=1ex,width=\paperwidth,height=\paperheight]
>>>> for i=1 upto 3:
>>>>  draw textext(\MPstring{i}) shifted(i*cm,i*cm) ;
>>>> endfor;
>>>> \stopMPpage
>>>>
>>>> \stoptext
>>>>
>>>> There is no error but no content either. What's wrong?
>>>
>>> Another way to do this is to use
>>>
>>> \TeXtext{1}{ABC} etc.
>>>
>>> and then call
>>>
>>> draw sometxt(i)
>>>
>>> For Sec 4.5 of Mojca's my way on sometxt 
>>> http://dl.contextgarden.net/myway/sometxt.pdf
>>
>> Thank you for the tip, I tried it, but sometext seems deprecated in 
>> mkiv ("[do we need TeXtexts in MkIV]").
> 
> I thought that you were using MKII.
> 
>> I've different buffers named 1–12 and would like to pipe them to 
>> Metapost. I thought I could use a textext(\getbuffer[i])-construct, it 
>> failed. So I tried it with \setMPtext{}{} …
>>
>> What is the approach to achieve this?
> 
> Well, if nothing else works, you can always cheat.
> 
> \startluacode
>   userdata = userdata or {}
>   userdata.labels = {
>     [1] = "ABC" ,
>     [2] = "DEF" ,
>     [3] = "GHI" }
> 
>   function userdata.shift(i)
>     return "(" .. i .. "cm ," .. i .. "cm )"
>   end
> 
>   function userdata.draw(i)
>     return "draw btex " .. userdata.labels[i] .. " etex  shifted ".. 
> userdata.shift(i) .. ";"
>   end
> 
> \stopluacode
> 
> \starttext
> 
> \startluacode
>   context.startMPpage({offset = "1ex", width = [[\paperwidth]], height = 
> [[\paperheight]]})
>     for i = 1,3 do
>       context(userdata.draw(i))
>     end
>   context.stopMPpage()
> \stopluacode
> 
> \stoptext

a nice example for the wiki

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-12 18:34     ` Mojca Miklavec
@ 2009-08-12 21:22       ` Hans Hagen
  2009-08-13 16:50         ` Andreas Harder
  2009-08-12 21:27       ` Andreas Harder
  1 sibling, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2009-08-12 21:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Mojca Miklavec wrote:
> On Wed, Aug 12, 2009 at 12:51, Andreas Harder wrote:
>> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>>
>>> Another way to do this is to use
>>>
>>> \TeXtext{1}{ABC} etc.
>>>
>>> and then call
>>>
>>> draw sometxt(i)
>>>
>>> For Sec 4.5 of Mojca's my way on sometxt
>>> http://dl.contextgarden.net/myway/sometxt.pdf

when processing that one i found out that

(1) syntax coloring was not enabled in mkii (due to tex->mkii renaming)
(2) labels were not centered by default

i fixed that

as a bonus i implemented TeXtext in mkiv ... so those who use it have to 
buy Mojca a beer some day ...

new beta

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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re:  loop textext and \MPstring{…}
  2009-08-12 18:34     ` Mojca Miklavec
  2009-08-12 21:22       ` Hans Hagen
@ 2009-08-12 21:27       ` Andreas Harder
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Harder @ 2009-08-12 21:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


Am 12.08.2009 um 20:34 schrieb Mojca Miklavec:
> I'm sure that there's a workaround (or at least a dozen of other
> ways), but I have no time (and my computer is being repaired again) to
> inspect right now.

Some tips?

> MKIV is both very powerful and fast, so you could probably also define
> strings inside metapost run, something like
>
> string mystrings[]; strings[1] := "ABC"; strings[2] = "DEF";
> draw textext(strings[1]);
>
> Untested.

It works, but if you loop it the problem remains.

Thanks!

	Andreas

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

[-- Attachment #2: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-12 14:53       ` Andreas Harder
@ 2009-08-13  3:00         ` Aditya Mahajan
  2009-08-13 16:41           ` Andreas Harder
  0 siblings, 1 reply; 13+ messages in thread
From: Aditya Mahajan @ 2009-08-13  3:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1357 bytes --]

On Wed, 12 Aug 2009, Andreas Harder wrote:

> In the "real world“ I've stripped quotes form another document and stored 
> them in buffer-environments (attachment).

Save them as lua tables. Much easier to manipulate than tex objects.

> With your solution I've no idea how 
> to incorporate them in a "automatic" manner.

You just need to work a little harder.

\startbuffer[1]
This is a test
\stopbuffer

\startbuffer[2]
Another test
\stopbuffer

\startbuffer[3]
And again
\stopbuffer

\startluacode
   userdata = userdata or {}
   function userdata.shift(i)
     return "(" .. i .. "cm ," .. i .. "cm )"
   end

   function userdata.buffers(i)
     local idx = string.format("%s",i)
     local b = buffers.data[idx]
     if b then
       if type(b) == "table" then
         return table.concat(b)
       else
         return b
       end
     else
       return "unknown"
     end
   end

   function userdata.draw_buffer(i)
     return "draw btex " .. userdata.buffers(i) .. " etex  shifted ".. 
userdata.shift(i) .. ";"
   end
\stopluacode

\starttext


\startluacode

   context.startMPpage({offset = "1ex", width = [[\paperwidth]], height = 
[[\paperheight]]})
     for i = 1,3 do
       context(userdata.draw_buffer(i))
     end
   context.stopMPpage()
\stopluacode

\stoptext

Aditya

[-- Attachment #2: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-13  3:00         ` Aditya Mahajan
@ 2009-08-13 16:41           ` Andreas Harder
  0 siblings, 0 replies; 13+ messages in thread
From: Andreas Harder @ 2009-08-13 16:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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


Am 13.08.2009 um 05:00 schrieb Aditya Mahajan:

> You just need to work a little harder.
>
> \startbuffer[1]
> This is a test
> \stopbuffer
>
> \startbuffer[2]
> Another test
> \stopbuffer
>
> \startbuffer[3]
> And again
> \stopbuffer
>
> \startluacode
>  userdata = userdata or {}
>  function userdata.shift(i)
>    return "(" .. i .. "cm ," .. i .. "cm )"
>  end
>
>  function userdata.buffers(i)
>    local idx = string.format("%s",i)
>    local b = buffers.data[idx]
>    if b then
>      if type(b) == "table" then
>        return table.concat(b)
>      else
>        return b
>      end
>    else
>      return "unknown"
>    end
>  end
>
>  function userdata.draw_buffer(i)
>    return "draw btex " .. userdata.buffers(i) .. " etex  shifted "..  
> userdata.shift(i) .. ";"
>  end
> \stopluacode
>
> \starttext
>
>
> \startluacode
>
>  context.startMPpage({offset = "1ex", width = [[\paperwidth]],  
> height = [[\paperheight]]})
>    for i = 1,3 do
>      context(userdata.draw_buffer(i))
>    end
>  context.stopMPpage()
> \stopluacode
>
> \stoptext

Thank you very much!

I played today (a couple of hours) with your solution and adapted some  
things, so if someone is interested, I've attached the file.



PS. I like the math.random() function I found in the Lua manual.

Andreas

[-- Attachment #1.2.1: Type: text/html, Size: 2078 bytes --]

[-- Attachment #1.2.2: MP-Luatext2.tex --]
[-- Type: application/x-tex, Size: 4865 bytes --]

[-- Attachment #1.2.3: Type: text/html, Size: 257 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re:  loop textext and \MPstring{…}
  2009-08-12 21:22       ` Hans Hagen
@ 2009-08-13 16:50         ` Andreas Harder
  0 siblings, 0 replies; 13+ messages in thread
From: Andreas Harder @ 2009-08-13 16:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 12.08.2009 um 23:22 schrieb Hans Hagen:

> Mojca Miklavec wrote:
>> On Wed, Aug 12, 2009 at 12:51, Andreas Harder wrote:
>>> Am 12.08.2009 um 07:40 schrieb Aditya Mahajan:
>>>
>>>> Another way to do this is to use
>>>>
>>>> \TeXtext{1}{ABC} etc.
>>>>
>>>> and then call
>>>>
>>>> draw sometxt(i)
>>>>
>>>> For Sec 4.5 of Mojca's my way on sometxt
>>>> http://dl.contextgarden.net/myway/sometxt.pdf
>
> when processing that one i found out that
>
> (1) syntax coloring was not enabled in mkii (due to tex->mkii  
> renaming)
> (2) labels were not centered by default
>
> i fixed that
>
> as a bonus i implemented TeXtext in mkiv ... so those who use it  
> have to buy Mojca a beer some day ...

Thank you for your help.

I've tried some examples form Mojca's MyWay but the pages still empty  
(without the "do we need …" question).

Anyway, Aditya's solution works.


Andreas
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2009-08-13 16:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11 14:08 loop textext and \MPstring{…} Andreas Harder
2009-08-11 22:07 ` Hans Hagen
2009-08-12  5:40 ` Aditya Mahajan
2009-08-12 10:51   ` Andreas Harder
2009-08-12 13:25     ` Aditya Mahajan
2009-08-12 14:53       ` Andreas Harder
2009-08-13  3:00         ` Aditya Mahajan
2009-08-13 16:41           ` Andreas Harder
2009-08-12 19:23       ` Hans Hagen
2009-08-12 18:34     ` Mojca Miklavec
2009-08-12 21:22       ` Hans Hagen
2009-08-13 16:50         ` Andreas Harder
2009-08-12 21:27       ` Andreas Harder

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