From: Hans Hagen <pragma@wxs.nl>
Subject: Re: 'empty string' test in MP
Date: Wed, 30 Nov 2005 09:51:24 +0100 [thread overview]
Message-ID: <438D680C.7070204@wxs.nl> (raw)
In-Reply-To: <438CC79D.3070906@gmx.net>
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
next prev parent reply other threads:[~2005-11-30 8:51 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 [this message]
2005-11-30 12:36 ` Peter Rolf
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=438D680C.7070204@wxs.nl \
--to=pragma@wxs.nl \
--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).