* Problem with arguments in macro
@ 2013-01-21 18:26 PELLOUIN Christophe
2013-01-21 18:32 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: PELLOUIN Christophe @ 2013-01-21 18:26 UTC (permalink / raw)
To: ntg-context
Hello,
When writing a macro, I observed that some arguments are not transmitted
correctly, particularly when the type is defined as "text".
Here is an example with the macro max defined in the file plain.mp
With this program:
beginfig(1)
show("first test");
show max (1,2,8,5,15,2,1,4);
numeric u_;
v_=15;
show("second test");
show max (1,2,8,5,v_,2,1,4);
numeric u_;
u_=15 % u_ variable is also defined in the macro max
show("third test");
show max (1,2,8,5,u_,2,1,4);
endfig;
end
The result is:
This is MetaPost, version 1.504 (kpathsea version 6.0.1)
(mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.004)) (./bizzare.mp
>> "first test"
>> 15
>> "second test"
>> 15
>> "third test"
>> 8 [1] )
1 output file written: bizzare.1
Transcript written on bizzare.log.
The third result is different because the variable u_ is defined in the
macro max of the file plain.mp
Christophe Pellouin
___________________________________________________________________________________
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] 5+ messages in thread
* Re: Problem with arguments in macro
2013-01-21 18:26 Problem with arguments in macro PELLOUIN Christophe
@ 2013-01-21 18:32 ` Hans Hagen
2013-01-21 19:47 ` PELLOUIN Christophe
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2013-01-21 18:32 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
> Hello,
>
> When writing a macro, I observed that some arguments are not transmitted
> correctly, particularly when the type is defined as "text".
> Here is an example with the macro max defined in the file plain.mp
> With this program:
>
> beginfig(1)
>
> show("first test");
> show max (1,2,8,5,15,2,1,4);
>
> numeric u_;
> v_=15;
> show("second test");
> show max (1,2,8,5,v_,2,1,4);
>
> numeric u_;
> u_=15 % u_ variable is also defined in the macro max
> show("third test");
> show max (1,2,8,5,u_,2,1,4);
>
> endfig;
> end
>
> The result is:
>
> This is MetaPost, version 1.504 (kpathsea version 6.0.1)
> (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
> Preloading the plain mem file, version 1.004)) (./bizzare.mp
> >> "first test"
> >> 15
> >> "second test"
> >> 15
> >> "third test"
> >> 8 [1] )
> 1 output file written: bizzare.1
> Transcript written on bizzare.log.
>
>
>
> The third result is different because the variable u_ is defined in the
> macro max of the file plain.mp
I can protect all local plain variables if needed but I'll only do it if
someone then tests all the plain macros.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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] 5+ messages in thread
* Re: Problem with arguments in macro
2013-01-21 18:32 ` Hans Hagen
@ 2013-01-21 19:47 ` PELLOUIN Christophe
2013-01-21 19:50 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: PELLOUIN Christophe @ 2013-01-21 19:47 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
Le 21/01/2013 19:32, Hans Hagen a écrit :
> On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
>> Hello,
>>
>> When writing a macro, I observed that some arguments are not transmitted
>> correctly, particularly when the type is defined as "text".
>> Here is an example with the macro max defined in the file plain.mp
>> With this program:
>>
>> beginfig(1)
>>
>> show("first test");
>> show max (1,2,8,5,15,2,1,4);
>>
>> numeric u_;
>> v_=15;
>> show("second test");
>> show max (1,2,8,5,v_,2,1,4);
>>
>> numeric u_;
>> u_=15 % u_ variable is also defined in the macro max
>> show("third test");
>> show max (1,2,8,5,u_,2,1,4);
>>
>> endfig;
>> end
>>
>> The result is:
>>
>> This is MetaPost, version 1.504 (kpathsea version 6.0.1)
>> (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
>> Preloading the plain mem file, version 1.004)) (./bizzare.mp
>> >> "first test"
>> >> 15
>> >> "second test"
>> >> 15
>> >> "third test"
>> >> 8 [1] )
>> 1 output file written: bizzare.1
>> Transcript written on bizzare.log.
>>
>>
>>
>> The third result is different because the variable u_ is defined in the
>> macro max of the file plain.mp
>
> I can protect all local plain variables if needed but I'll only do it
> if someone then tests all the plain macros.
How can I protect a variable? I had the same bug in one of my macros and
I'd like to fix it.
Thanks
>
> Hans
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 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] 5+ messages in thread
* Re: Problem with arguments in macro
2013-01-21 19:47 ` PELLOUIN Christophe
@ 2013-01-21 19:50 ` Hans Hagen
2013-01-21 20:25 ` PELLOUIN Christophe
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2013-01-21 19:50 UTC (permalink / raw)
To: PELLOUIN Christophe; +Cc: mailing list for ConTeXt users
On 1/21/2013 8:47 PM, PELLOUIN Christophe wrote:
> Le 21/01/2013 19:32, Hans Hagen a écrit :
>> On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
>>> Hello,
>>>
>>> When writing a macro, I observed that some arguments are not transmitted
>>> correctly, particularly when the type is defined as "text".
>>> Here is an example with the macro max defined in the file plain.mp
>>> With this program:
>>>
>>> beginfig(1)
>>>
>>> show("first test");
>>> show max (1,2,8,5,15,2,1,4);
>>>
>>> numeric u_;
>>> v_=15;
>>> show("second test");
>>> show max (1,2,8,5,v_,2,1,4);
>>>
>>> numeric u_;
>>> u_=15 % u_ variable is also defined in the macro max
>>> show("third test");
>>> show max (1,2,8,5,u_,2,1,4);
>>>
>>> endfig;
>>> end
>>>
>>> The result is:
>>>
>>> This is MetaPost, version 1.504 (kpathsea version 6.0.1)
>>> (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
>>> Preloading the plain mem file, version 1.004)) (./bizzare.mp
>>> >> "first test"
>>> >> 15
>>> >> "second test"
>>> >> 15
>>> >> "third test"
>>> >> 8 [1] )
>>> 1 output file written: bizzare.1
>>> Transcript written on bizzare.log.
>>>
>>>
>>>
>>> The third result is different because the variable u_ is defined in the
>>> macro max of the file plain.mp
>>
>> I can protect all local plain variables if needed but I'll only do it
>> if someone then tests all the plain macros.
>
> How can I protect a variable? I had the same bug in one of my macros and
> I'd like to fix it.
my_private_u
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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] 5+ messages in thread
* Re: Problem with arguments in macro
2013-01-21 19:50 ` Hans Hagen
@ 2013-01-21 20:25 ` PELLOUIN Christophe
0 siblings, 0 replies; 5+ messages in thread
From: PELLOUIN Christophe @ 2013-01-21 20:25 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
Le 21/01/2013 20:50, Hans Hagen a écrit :
> On 1/21/2013 8:47 PM, PELLOUIN Christophe wrote:
>> Le 21/01/2013 19:32, Hans Hagen a écrit :
>>> On 1/21/2013 7:26 PM, PELLOUIN Christophe wrote:
>>>> Hello,
>>>>
>>>> When writing a macro, I observed that some arguments are not
>>>> transmitted
>>>> correctly, particularly when the type is defined as "text".
>>>> Here is an example with the macro max defined in the file plain.mp
>>>> With this program:
>>>>
>>>> beginfig(1)
>>>>
>>>> show("first test");
>>>> show max (1,2,8,5,15,2,1,4);
>>>>
>>>> numeric u_;
>>>> v_=15;
>>>> show("second test");
>>>> show max (1,2,8,5,v_,2,1,4);
>>>>
>>>> numeric u_;
>>>> u_=15 % u_ variable is also defined in the macro max
>>>> show("third test");
>>>> show max (1,2,8,5,u_,2,1,4);
>>>>
>>>> endfig;
>>>> end
>>>>
>>>> The result is:
>>>>
>>>> This is MetaPost, version 1.504 (kpathsea version 6.0.1)
>>>> (mpost.mp (c:/texlive/2011/texmf-dist/metapost/base/plain.mp
>>>> Preloading the plain mem file, version 1.004)) (./bizzare.mp
>>>> >> "first test"
>>>> >> 15
>>>> >> "second test"
>>>> >> 15
>>>> >> "third test"
>>>> >> 8 [1] )
>>>> 1 output file written: bizzare.1
>>>> Transcript written on bizzare.log.
>>>>
>>>>
>>>>
>>>> The third result is different because the variable u_ is defined in
>>>> the
>>>> macro max of the file plain.mp
>>>
>>> I can protect all local plain variables if needed but I'll only do it
>>> if someone then tests all the plain macros.
>>
>> How can I protect a variable? I had the same bug in one of my macros and
>> I'd like to fix it.
>
> my_private_u
Ok. Thank you
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 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] 5+ messages in thread
end of thread, other threads:[~2013-01-21 20:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-21 18:26 Problem with arguments in macro PELLOUIN Christophe
2013-01-21 18:32 ` Hans Hagen
2013-01-21 19:47 ` PELLOUIN Christophe
2013-01-21 19:50 ` Hans Hagen
2013-01-21 20:25 ` PELLOUIN Christophe
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).