From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/12622 Path: main.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: variables Date: Tue, 15 Jul 2003 16:22:23 +0200 Organization: Elvenkind Sender: ntg-context-admin@ntg.nl Message-ID: <20030715162223.5116578c.taco@elvenkind.com> References: <3F13FAC0.4040502@arcor.de> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1058279268 6337 80.91.224.249 (15 Jul 2003 14:27:48 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 15 Jul 2003 14:27:48 +0000 (UTC) Cc: peter.rolf@arcor.de Original-X-From: ntg-context-admin@ntg.nl Tue Jul 15 16:27:47 2003 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19cQkk-0001R0-00 for ; Tue, 15 Jul 2003 16:26:02 +0200 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id 044F910B51; Tue, 15 Jul 2003 16:26:45 +0200 (MEST) Original-Received: from glenfiddich.elvenkind.com (elvenknd.xs4all.nl [213.84.171.68]) by ref.ntg.nl (Postfix) with ESMTP id 2BE8310B34 for ; Tue, 15 Jul 2003 16:22:24 +0200 (MEST) Original-Received: from glenlivet.elvenkind.com (glenlivet.elvenkind.com [10.10.0.6]) by glenfiddich.elvenkind.com (Postfix) with SMTP id CB3CBCE27; Tue, 15 Jul 2003 16:22:19 +0200 (CEST) Original-To: ntg-context@ntg.nl In-Reply-To: <3F13FAC0.4040502@arcor.de> X-Mailer: Sylpheed version 0.8.11claws (GTK+ 1.2.10; i686-pc-linux-gnu) Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:12622 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:12622 On Tue, 15 Jul 2003 14:59:44 +0200, Peter wrote: > I want to test, if a given variable is empty or not. I tried the following, > but the test is always false. Is this a bug or a feature ;) It is a feature/bug of TeX itself that "\if" tests perform a conditionality test that is not even remotely intuitive ;-) The '\if' looks ahead to see if the next two non-expandable tokens have the same 'character code' *after* expansion. It will actually compare 's' to 'o' in the "second" example (false). The input "second=oops" would have given a 'true' result, but would also have typeset the extra letters ('ps') as a side-effect. TeX's \if test can be quite confusing and should normally not be used in a document. It is much better to use one of ConTeXt's predefined commands, like this one: \doifelse {\TestVAR{first}} {} {The variable test:first is empty.} {The variable test:first contains \TestVAR{first}.} this compares argument #1 to argument #2, executing #3 or #4 depending on the outcome of the test. Greetings, Taco > Any help is welcome. > > > \starttext > > \setvariables[test] > [first=, > second=something,] > > \def\TestVAR#1{\getvariable{test}{#1}} > > \if\TestVAR{first}\empty % > The variable test:first is empty.\else > The variable test:first contains \TestVAR{first}.\fi > > \if\TestVAR{second}\empty % > The variable test:second is empty.\else > The variable test:second contains \TestVAR{second}.\fi > > \stoptext > > > Regards, > > Peter > > > _______________________________________________ > ntg-context mailing list > ntg-context@ntg.nl > http://www.ntg.nl/mailman/listinfo/ntg-context -- groeten, Taco