🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #2613

Re: detecting missing arguments in latex

#2613
From: Michial Gunter
Date: Fri, 11 Sep 1992 16:30
51 lines
1837 bytes
In article <1992Sep11.201211.29920@constellation.ecn.uoknor.edu> wszczepo@wildcat.ecn.uoknor.edu (Witold Szczeponik) writes:

> I ran into the same problem some days ago.  Here's a piece of the
> code that tests whether the first argument is empty or not:
>     {\setbox0=\hbox{\ignorespaces#1\unskip\relax}%
>     \ifdim \wd0=0pt%
> % do whatever you want if the argument is empty
>     \else%
> % do whatever you want if it isn't
>     \fi%
>    }%


This works and is more general than the above solution (it does not
falsely declare an argument null if the argument produces no text.)

Almost certainly there are better solutions.

			mike


\def\makeatletter{\catcode`\@=11\relax}
\def\makeatother{\catcode`\@=12\relax}
\makeatletter
\def\ifnullarg#1\ifnullarg#2#3{%
\begingroup
	\def\@flag{\relax\relax\relax}
	\def\@na@yes{#2}%
	\def\@na@no{#3}%
	\ifx\@flag#1\@flag\let\@na@chosen=\@na@yes
	\else\let\@na@chosen=\@na@no\fi
	\relax
	\@na@chosen
\endgroup
}
\makeatother

% Testing -- Cut here --

\def\iw#1{\immediate\write16{#1}}

\def\usenullchk#1{%
	\ifnullarg#1\ifnullarg{\iw{Null}}%
			{\iw{Not Null}}}
	
\usenullchk{}
\usenullchk{foo}
\usenullchk{\relax}

\end
Technical Details
Message-ID: <GUNTER.92Sep11163020@chirk.cs.ucla.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!ucla-cs!kona!gunter
References: <6725@vtserf.cc.vt.edu> <1992Sep11.201211.29920@constellation.ecn.uoknor.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!ucla-cs!kona!gunter
From: gunter@chirk.cs.ucla.edu (Michial Gunter)
Subject: Re: detecting missing arguments in latex
In-Reply-To: wszczepo@wildcat.ecn.uoknor.edu's message of Fri, 11 Sep 1992 20:12:11 GMT
Message-ID: <GUNTER.92Sep11163020@chirk.cs.ucla.edu>
Sender: usenet@cs.ucla.edu (Mr Usenet)
Nntp-Posting-Host: chirk.cs.ucla.edu
Organization: /global/us/edu/ucla/cs/ficus/users/gunter/.organization
References: <6725@vtserf.cc.vt.edu> <1992Sep11.201211.29920@constellation.ecn.uoknor.edu>
Date: 11 Sep 92 16:30:20
Lines: 51