From: Peter Rolf <indiego@gmx.net>
Subject: Re: 'empty string' test in MP
Date: Wed, 30 Nov 2005 13:36:59 +0100 [thread overview]
Message-ID: <438D9CEB.9000303@gmx.net> (raw)
In-Reply-To: <438D680C.7070204@wxs.nl>
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
>
>
prev parent reply other threads:[~2005-11-30 12:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-29 21:26 Peter Rolf
2005-11-30 8:51 ` Hans Hagen
2005-11-30 12:36 ` Peter Rolf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=438D9CEB.9000303@gmx.net \
--to=indiego@gmx.net \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).