🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2619

Re: detecting missing arguments in latex

#2619
From: Donald Arseneau
Date: Sat, 12 Sep 1992 02:21
38 lines
2037 bytes
In article <6725@vtserf.cc.vt.edu>, gbol@rglnext.geol.vt.edu (Gregory Lampshire) writes...
> 
> 
>I want to set up a macro 
>	\if <argument #1 is null> do this etc.
>	\else etc.
>	\fi

There are a number of ways to do this, but the following is the best.
(Best in most senses...but not in clarity!)
There are two types of syntax to check for null parameters:
\ifnull{#1}\then ... \else...\fi
\if\naught{#1}...\else...\fi
Choose the definitions that correspond to the desired syntax.

%========================================================================
%  \ifblank --- checks if parameter is blank (Spaces count as blank)
%  \ifgiven --- checks if parameter is not blank: like \ifblank\else
%  \ifnull  --- checks if parameter is null (spaces are NOT null)
%     use \ifgiven{#1}\then   ...  \else  ...  \fi   etc
\let\then\iftrue
{\catcode`\!=8 % funny catcode so ! will be a delimiter
\long\gdef\ifgiven#1\then{\Ifbl@nk#1@@@\empty!}% negative of \ifblank
\long\gdef\ifblank#1\then{\Ifbl@nk#1@@..!}% if null or spaces
\long\gdef\Ifbl@nk#1#2@#3#4!{\ifx#3#4}
\long\gdef\ifnull#1\then{\IfN@LL#1* {#1}!}% if null
\long\gdef\IfN@LL#1 #2!{\ifblank{#2}\then}
%
%
%  or.... use \if\given, \if\blank, \if\naught (\null already exists)
%  without \then.
%
\long\gdef\given#1{\fi\Ifbl@nk#1@@@\empty!}
\long\gdef\blank#1{\fi\Ifbl@nk#1@@..!}% if null or spaces
\long\gdef\naught#1{\IfN@Ught#1* {#1}!}% if null
\long\gdef\IfN@Ught#1 #2!{\blank{#2}}
\long\gdef\Ifbl@nk#1#2@#3#4!{\ifx#3#4}
}
Technical Details
Message-ID: <11SEP199219213030@msr.triumf.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!ubc-cs!unixg.ubc.ca!msr.triumf.ca!asnd
References: <6725@vtserf.cc.vt.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!gumby!destroyer!ubc-cs!unixg.ubc.ca!msr.triumf.ca!asnd
From: asnd@msr.triumf.ca (Donald Arseneau)
Subject: Re: detecting missing arguments in latex
Message-ID: <11SEP199219213030@msr.triumf.ca>
News-Software: VAX/VMS VNEWS 1.41    
Sender: news@unixg.ubc.ca (Usenet News Maintenance)
Nntp-Posting-Host: msr.triumf.ca
Organization: TRIUMF: Tri-University Meson Facility
References: <6725@vtserf.cc.vt.edu>
Date: Sat, 12 Sep 1992 02:21:00 GMT
Lines: 38