Skip to main content
added 4 characters in body
Source Link

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthen package:

\newboolean{default} \newcommand{\case}{} \newcommand{\default}{} \newenvironment{switch}[1]{% \setboolean{default}{true} \renewcommand{\case}[2]{\ifthenelse{\equal{#1}{##1}}{% \setboolean{default}{false}##2}{}}% \renewcommand{\default}[1]{\ifthenelse{\boolean{default}}{##1}{}} 

}{}

}{} Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious, this was a program for an off-season sports conditioning program and was being looped with datatool, the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthen package:

\newboolean{default} \newcommand{\case}{} \newcommand{\default}{} \newenvironment{switch}[1]{% \setboolean{default}{true} \renewcommand{\case}[2]{\ifthenelse{\equal{#1}{##1}}{% \setboolean{default}{false}##2}{}}% \renewcommand{\default}[1]{\ifthenelse{\boolean{default}}{##1}{}} 

}{}

Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious, this was a program for an off-season sports conditioning program and was being looped with datatool, the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthen package:

\newboolean{default} \newcommand{\case}{} \newcommand{\default}{} \newenvironment{switch}[1]{% \setboolean{default}{true} \renewcommand{\case}[2]{\ifthenelse{\equal{#1}{##1}}{% \setboolean{default}{false}##2}{}}% \renewcommand{\default}[1]{\ifthenelse{\boolean{default}}{##1}{}} }{} Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious, this was a program for an off-season sports conditioning program and was being looped with datatool, the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

I caught a mistake that only allowed this to be run once within a document. This edit fixes that.
Source Link

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthenelseifthen package:

\newboolean{elsedefault}  \setboolean\newcommand{else\case}{true}  \newcommand{\ifequal\default}[3]{\ifthenelse{\equal{#1} \newenvironment{#2}switch}[1]{% \setboolean{else}{false}#3default}{}true}    \newcommand \renewcommand{\checkbool\case}[1][2]{\ifthenelse{\boolean{else}}\equal{#1}{##1}} \newcommand{\case}[2]{#1 #2} % \newcommand{\default}[2]{#1 #2}     \newenvironment{switch}[1]{    \renewcommand \setboolean{\casedefault}{\ifequalfalse}##2}{#1}}%     \renewcommand{\default}[1]{\checkbool\ifthenelse{\boolean{default} }{##1}  {}} 

}{}

Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious, this was a program for an off-season sports conditioning program and was being looped with datatooldatatool, the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthenelse:

\newboolean{else}  \setboolean{else}{true}  \newcommand{\ifequal}[3]{\ifthenelse{\equal{#1}{#2}}{\setboolean{else}{false}#3}{}}  \newcommand{\checkbool}[1]{\ifthenelse{\boolean{else}}{#1}{}} \newcommand{\case}[2]{#1 #2}  \newcommand{\default}[2]{#1 #2}     \newenvironment{switch}[1]{    \renewcommand{\case}{\ifequal{#1}}    \renewcommand{\default}{\checkbool} }{}   Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious this was a program for an off-season conditioning program and was being looped with datatool the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthen package:

\newboolean{default} \newcommand{\case}{} \newcommand{\default}{} \newenvironment{switch}[1]{% \setboolean{default}{true}    \renewcommand{\case}[2]{\ifthenelse{\equal{#1}{##1}}{%  \setboolean{default}{false}##2}{}}%  \renewcommand{\default}[1]{\ifthenelse{\boolean{default}}{##1}{}} 

}{}

Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious, this was a program for an off-season sports conditioning program and was being looped with datatool, the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

added 80 characters in body
Source Link

Based on the great answer by Thev and updated by MaxD I have implemented a \default\default command for switch. I used ifthenelse:

\newboolean{else}
\setboolean{else}{true}
\newcommand{\ifequal}[3]{\ifthenelse{\equal{#1}{#2}}{\setboolean{else}{false}#3}{}}
\newcommand{\checkbool}[1]{\ifthenelse{\boolean{else}}{#1}{}}
\newcommand{\case}[2]{#1 #2}
\newcommand{\default}[2]{#1 #2}

\newenvironment{switch}[1]{
\renewcommand{\case}{\ifequal{#1}}
\renewcommand{\default}{\checkbool}
}{}

Then implement it as suchifthenelse:

\begin{switch}{\program}
\case{2}{\twodayprogram}
\case{4}{\fourdayprogram}
\default{\first\ \last\ missing program\pagebreak}
\end{switch}

\newboolean{else} \setboolean{else}{true} \newcommand{\ifequal}[3]{\ifthenelse{\equal{#1}{#2}}{\setboolean{else}{false}#3}{}} \newcommand{\checkbool}[1]{\ifthenelse{\boolean{else}}{#1}{}} \newcommand{\case}[2]{#1 #2} \newcommand{\default}[2]{#1 #2} \newenvironment{switch}[1]{ \renewcommand{\case}{\ifequal{#1}} \renewcommand{\default}{\checkbool} }{} Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious this was a program for an off-season conditioning program and was being looped with datatool the commands "\twodayprogram"\twodayprogram and "\fourdayprogram"\fourdayprogram implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthenelse:

\newboolean{else}
\setboolean{else}{true}
\newcommand{\ifequal}[3]{\ifthenelse{\equal{#1}{#2}}{\setboolean{else}{false}#3}{}}
\newcommand{\checkbool}[1]{\ifthenelse{\boolean{else}}{#1}{}}
\newcommand{\case}[2]{#1 #2}
\newcommand{\default}[2]{#1 #2}

\newenvironment{switch}[1]{
\renewcommand{\case}{\ifequal{#1}}
\renewcommand{\default}{\checkbool}
}{}

Then implement it as such:

\begin{switch}{\program}
\case{2}{\twodayprogram}
\case{4}{\fourdayprogram}
\default{\first\ \last\ missing program\pagebreak}
\end{switch}

in case anyone is curious this was a program for an off-season conditioning program and was being looped with datatool the commands "\twodayprogram" and "\fourdayprogram" implement the program for a particular athlete

Based on the great answer by Thev and updated by MaxD I have implemented a \default command for switch. I used ifthenelse:

\newboolean{else} \setboolean{else}{true} \newcommand{\ifequal}[3]{\ifthenelse{\equal{#1}{#2}}{\setboolean{else}{false}#3}{}} \newcommand{\checkbool}[1]{\ifthenelse{\boolean{else}}{#1}{}} \newcommand{\case}[2]{#1 #2} \newcommand{\default}[2]{#1 #2} \newenvironment{switch}[1]{ \renewcommand{\case}{\ifequal{#1}} \renewcommand{\default}{\checkbool} }{} Then implement it as such: \begin{switch}{\program} \case{2}{\twodayprogram} \case{4}{\fourdayprogram} \default{\first\ \last\ missing program\pagebreak} \end{switch} 

in case anyone is curious this was a program for an off-season conditioning program and was being looped with datatool the commands \twodayprogram and \fourdayprogram implement the program for a particular athlete

Source Link
Loading