From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/31215 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: programming: doifdefined & friends Date: Thu, 5 Oct 2006 00:04:50 -0400 (EDT) Message-ID: References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1160021119 773 80.91.229.2 (5 Oct 2006 04:05:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 5 Oct 2006 04:05:19 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Oct 05 06:05:16 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1GVKTs-0004Mo-9V for gctc-ntg-context-518@m.gmane.org; Thu, 05 Oct 2006 06:05:09 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id D64541FCEC; Thu, 5 Oct 2006 06:05:06 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22863-05-3; Thu, 5 Oct 2006 06:05:02 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9532C1FCC7; Thu, 5 Oct 2006 06:05:01 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id DF7621FCC7 for ; Thu, 5 Oct 2006 06:04:57 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22863-05-2 for ; Thu, 5 Oct 2006 06:04:53 +0200 (CEST) Original-Received: from hellskitchen.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.14.82]) by ronja.ntg.nl (Postfix) with SMTP id 6A3FB1FCAA for ; Thu, 5 Oct 2006 06:04:51 +0200 (CEST) Original-Received: FROM aditya.annarb01.mi.comcast.net (c-68-40-50-205.hsd1.mi.comcast.net [68.40.50.205]) BY hellskitchen.mr.itd.umich.edu ID 45248462.87590.27601 ; 5 Oct 2006 00:04:50 -0400 Original-To: mailing list for ConTeXt users In-Reply-To: X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:31215 Archived-At: 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