From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: programming: doifdefined & friends
Date: Thu, 5 Oct 2006 00:04:50 -0400 (EDT) [thread overview]
Message-ID: <Pine.WNT.4.63.0610042353230.2232@nqvgln> (raw)
In-Reply-To: <A6B13FFF-B2C2-4BD5-9996-025BA13344A8@fiee.net>
On Thu, 5 Oct 2006, Henning Hraban Ramm wrote:
> While I can't cope with counters, I'm trying other stuff that I don't
> understand:
> How must I use \doifdefined & friends?
>
> Consider this snippet:
>
> -----
> \starttext
>
> \def\myvar{JAJAJA}
>
> \input tufte
> \doifdefined{\myvar}{\par bla \myvar blub\par}
> \input tufte
>
> \stoptext
> -----
>
> I'd guess it would print "bla JAJAJAblub" between the two Tufte texts
> and don't if I comment \def\myvar.
>
> But I guess wrongly: It does nothing in this case, and complains
> about undefined \myvar in the latter.
That is because \doifdefined is for strings. It adds a \csname ...
\endcsname around its first argument.
> But if I really want to check if something is defined before I try to
> use it, how must I write it?
The plain tex way
\ifx\myvar\undefined
%Nothing here
\else
\par bla \myvar blub\par
\fi
or the context way (for strings)
\doifdefined{myvar}{\par bla \myvar blub\par}
Aditya
prev parent reply other threads:[~2006-10-05 4:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-05 0:42 Henning Hraban Ramm
2006-10-05 0:56 ` Henning Hraban Ramm
2006-10-05 1:15 ` Henning Hraban Ramm
2006-10-05 4:04 ` Aditya Mahajan [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=Pine.WNT.4.63.0610042353230.2232@nqvgln \
--to=adityam@umich.edu \
--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).