Thank you Hans, this is exactly what I need.
I will wikify the examples.
Kind regards,
Jan Willem Flamma
From: Hans Hagen
Sent: Friday, 4 September 2020 15:09
To: mailing list for ConTeXt users; Jan Willem Flamma
Subject: Re: [NTG-context] Combining modes and MetaFun
On 9/4/2020 2:20 PM, Jan Willem Flamma wrote:
> Dear list members,
>
> Is it possible to combine modes and MetaFun?
>
> In the below MWE, the \doifmode construction does not work.
>
> Kind regards,
>
> Jan Willem Flamma
>
> ===
>
> \enablemode[en]
>
> %\enablemode[nl]
>
> \starttext
>
> \startbuffer[square]
>
> u := 2cm ;
>
> draw unitsquare scaled u ;
>
> drawdblarrow (0,-0.2u)..(u,-0.2u) ;
>
> drawdblarrow (1.2u, 0)..(1.2u, u) ;
>
> %\doifmode{en}{label(\sometxt{length}, (0.5u,-0.4u)) ;}
>
> %\doifmode{nl}{label(\sometxt{lengte}, (0.5u,-0.4u)) ;}
>
> %\doifmode{en}{label(\sometxt{width}, (1.6u, 0.5u)) ;}
>
> %\doifmode{nl}{label(\sometxt{breedte}, (1.6u, 0.5u)) ;}
>
> \stopbuffer
>
> \placefigure
>
> [here,none][]{}
>
> {\scale[width=0.5\textwidth]{\processMPbuffer[square]}}
>
> \stoptext
You need to compensate these solutions by "wikifying" them:
\starttext
\startuseMPgraphic{whatever}{s::mode}
u := 2cm ;
draw unitsquare scaled u ;
drawdblarrow (0,-0.2u)..(u,-0.2u) ;
drawdblarrow (1.2u, 0)..(1.2u, u) ;
if "\MPvar{mode}" = "en" :
label("e", (0.5u,-0.4u)) ;
label("n", (1.6u, 0.5u)) ;
else :
label("n", (0.5u,-0.4u)) ;
label("l", (1.6u, 0.5u)) ;
fi ;
\stopuseMPgraphic
\useMPgraphic{whatever}{mode=en} \blank
\useMPgraphic{whatever}{mode=nl} \blank
\startuseMPgraphic{whatever}
u := 2cm ;
draw unitsquare scaled u ;
drawdblarrow (0,-0.2u)..(u,-0.2u) ;
drawdblarrow (1.2u, 0)..(1.2u, u) ;
if texmode("en") :
label("e", (0.5u,-0.4u)) ;
label("n", (1.6u, 0.5u)) ;
else :
label("n", (0.5u,-0.4u)) ;
label("l", (1.6u, 0.5u)) ;
fi ;
\stopuseMPgraphic
{ \enablemode[en] \useMPgraphic{whatever} } \blank
{ \useMPgraphic{whatever} } \blank
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------