I'd like to construct a conditional \iffalse and \fi.
Specifically, I'd like to define a counter and a macro such that if the counter set to one,the macro would either set an \iffalse, if the argument to the macro were "on", or a \fi, if the argument to the macro were "off". Similar questions have been asked in this thread and this one but both involve more complicated constructions than my simple one.
In the code below, I define a counter Skip and a macro \mySkip which, if correctly defined, would, if \Skip were set to 1, would return \iffalse in response to the line \mySkip{on} and \fi in response to the line \mySkip{off}. If \Skip were set to 0, the macro would be ignored. In this way, I could alter one line of my code, and thus display or not display large sections of text.
The macro, instead of suppressing the text between \mySkip{on} and \mySkip{off} merely postpones printing the text between \mySkip{on} and \mySkip{off} until after the \mySkip{\off}. Is there a way to fix this?
Thanks for any advice.
\documentclass{article}
\usepackage{pdftexcmds}
\usepackage{ifthen}
\makeatother
\newif\ifstrcmp
\makeatletter
\def\isstrcmp#1#2{
\ifnum\pdf@strcmp{#1}{#2}=0
\strcmptrue
\else
\strcmpfalse
\fi
}
\makeatother
\newcounter{Skip}
\def\mySkip#1{\ifthenelse{\theSkip=1}{
\isstrcmp{#1}{on}
\ifstrcmp
\iffalse
\else
\fi
Text should resume after this\\
\fi
}{
}}
\begin{document}
\setcounter{Skip}{1}
\mySkip{on}
This line should be skipped because it's between an ``iffalse'' and a ``fi''\\
In fact it's ``postponed" till immediately after the macro is ``closed"\\ \\
\mySkip{off}
This is the first line after the macro has been closed
\end{document}

comment.sty? It offers a more user-friendly interface than having to fiddle with counters. – jon May 08 '16 at 03:48minimalfor examples. – cfr May 08 '16 at 12:31