* 'empty string' test in MP
@ 2005-11-29 21:26 Peter Rolf
2005-11-30 8:51 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Peter Rolf @ 2005-11-29 21:26 UTC (permalink / raw)
Hi all,
I pass a string to a MP graphic using \setMPtext{LABEL}{TEXT}. The
string can also be empty, and then no action (for the text) is taken.
How can I test in MP, if the given \MPstring{LABEL} is empty?
I have tried everything I can imagine in the last one hour, but no
success. Not my day...
This is the old, not working version
if not(\MPstring{LABEL}="") : % is always true.
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'empty string' test in MP
2005-11-29 21:26 'empty string' test in MP Peter Rolf
@ 2005-11-30 8:51 ` Hans Hagen
2005-11-30 12:36 ` Peter Rolf
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2005-11-30 8:51 UTC (permalink / raw)
Peter Rolf wrote:
>Hi all,
>
>I pass a string to a MP graphic using \setMPtext{LABEL}{TEXT}. The
>string can also be empty, and then no action (for the text) is taken.
>How can I test in MP, if the given \MPstring{LABEL} is empty?
>
>I have tried everything I can imagine in the last one hour, but no
>success. Not my day...
>
>This is the old, not working version
>
>if not(\MPstring{LABEL}="") : % is always true.
>
>
>
unless to set it to nothign (currently you don't assign it at all)
take this:
\setupcolors[state=start]
\starttext
\startuseMPgraphic{test}
fill fullcircle
scaled 1cm
withcolor if not(\MPstring{XX}="") : red else : green fi ;
\stopuseMPgraphic
\useMPgraphic{test} \start \setMPtext{XX}{} \useMPgraphic{test} \stop
\unprotect
\def\MPtext #1{\executeifdefined{\@@MPT#1}\empty}
\def\MPstring #1{"\executeifdefined{\@@MPT#1}\empty"}
\def\MPbetex #1{btex \executeifdefined{\@@MPT#1}\empty etex}
\protect
\useMPgraphic{test} \start \setMPtext{XX}{} \useMPgraphic{test} \stop
\stoptext
the current definitions return "\relax" when a text is not defined; i'll
change the definitions
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'empty string' test in MP
2005-11-30 8:51 ` Hans Hagen
@ 2005-11-30 12:36 ` Peter Rolf
0 siblings, 0 replies; 3+ messages in thread
From: Peter Rolf @ 2005-11-30 12:36 UTC (permalink / raw)
Hans Hagen wrote:
> Peter Rolf wrote:
>
>> Hi all,
>>
>> I pass a string to a MP graphic using \setMPtext{LABEL}{TEXT}. The
>> string can also be empty, and then no action (for the text) is taken.
>> How can I test in MP, if the given \MPstring{LABEL} is empty?
>>
>> I have tried everything I can imagine in the last one hour, but no
>> success. Not my day...
>>
>> This is the old, not working version
>>
>> if not(\MPstring{LABEL}="") : % is always true.
>>
>>
>>
> unless to set it to nothign (currently you don't assign it at all)
>
yes and no. I had an older macro
\XXmacro[#1]#2{%
...
\ifsecondargument\setMPtext{XX}{\SomeFontsettings\strut#2}\else\setMPtext{XX}{}\fi
which is naturally always true. I replaced it with a \doiftextelse and
now everything is working as expected.
Thanks for the enlightenment and the nice example :)
Peter
> take this:
>
> \setupcolors[state=start]
>
> \starttext
>
> \startuseMPgraphic{test}
> fill fullcircle
> scaled 1cm
> withcolor if not(\MPstring{XX}="") : red else : green fi ;
> \stopuseMPgraphic
>
> \useMPgraphic{test} \start \setMPtext{XX}{} \useMPgraphic{test} \stop
>
> \unprotect
>
> \def\MPtext #1{\executeifdefined{\@@MPT#1}\empty}
> \def\MPstring #1{"\executeifdefined{\@@MPT#1}\empty"}
> \def\MPbetex #1{btex \executeifdefined{\@@MPT#1}\empty etex}
>
> \protect
>
> \useMPgraphic{test} \start \setMPtext{XX}{} \useMPgraphic{test} \stop
>
> \stoptext
>
> the current definitions return "\relax" when a text is not defined; i'll
> change the definitions
>
> Hans
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-11-30 12:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-29 21:26 'empty string' test in MP Peter Rolf
2005-11-30 8:51 ` Hans Hagen
2005-11-30 12:36 ` Peter Rolf
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).