From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/12628 Path: main.gmane.org!not-for-mail From: Peter Rolf Newsgroups: gmane.comp.tex.context Subject: Re: variables Date: Wed, 16 Jul 2003 11:11:38 +0200 Sender: ntg-context-admin@ntg.nl Message-ID: <3F1516CA.1000007@arcor.de> References: <3F13FAC0.4040502@arcor.de> <20030715162223.5116578c.taco@elvenkind.com> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1058346889 13021 80.91.224.249 (16 Jul 2003 09:14:49 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 16 Jul 2003 09:14:49 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Wed Jul 16 11:14:45 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 19ciN2-0003NR-00 for ; Wed, 16 Jul 2003 11:14:44 +0200 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id DD5F910B41; Wed, 16 Jul 2003 11:15:37 +0200 (MEST) Original-Received: from mail-in-02.arcor-online.net (mail-in-02.arcor-online.net [151.189.21.42]) by ref.ntg.nl (Postfix) with ESMTP id 41A1610B3F for ; Wed, 16 Jul 2003 11:11:14 +0200 (MEST) Original-Received: from arcor.de (dialin-145-254-094-117.arcor-ip.net [145.254.94.117]) by mail-in-02.arcor-online.net (Postfix) with ESMTP id A0B5825FD9 for ; Wed, 16 Jul 2003 11:12:42 +0200 (CEST) User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en Original-To: ntg-context@ntg.nl In-Reply-To: <20030715162223.5116578c.taco@elvenkind.com> 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:12628 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:12628 Thank you Taco for your exact answer. I will use \doifelse instead :) Regards, Peter Taco Hoekwater wrote: >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 >> >> > > > >