I'm new at making macros and am in the process of building a package to produce course outlines. I want the user to input room/day/time information as below (where everything has been simplified to just using the room)
\newcounter{RoomCount}
\NewDocumentCommand\Room{R(){TBA}}{%
\stepcounter{RoomCount}%
\expandafter\newcommand\csname Room\theRoomCount\endcsname{#1}%
}
At this point I would like to feed this information into a tabular environment to format the room/day/time information. To do so, I would like a macro that spits out 1 row for each room/day/time combination that has been input. This macro would then be executed in a tabular environment to build the table.
\NewDocumentCommand\buildrows{}{%
\newbool{myBool}%
\booltrue{myBool}%
\newcounter{rownum}%
\whileboolexpr{myBool}{%
\stepcounter{rownum}%
\ifcsdef{Room\therownum}%
{\csname Room\therownum\endcsname\\}%
{\boolfalse{myBool}}%
}%
}
The intention of the loop is: check whether the user has input a second room, if so, then write a row for tabular, if not, then set myBool to false so that the loop exits. The following, however, produces many "package etoolbox error: invalid boolean expression" errors
\begin{document}
\Room(C244)
\begin{tabular}{l}
\buildrows{}
\end{tabular}
\end{document}
At this point I don't have enough "tools in my toolbox" to figure out what I'm doing wrong so any help/suggestions would be greatly appreciated. Thanks! ps. The full example would be:
\documentclass{report}
\usepackage{xparse}
\usepackage{etoolbox}
\newcounter{RoomCount}
\NewDocumentCommand\Room{+R(){TBA}}{%
\stepcounter{RoomCount}%
\expandafter\newcommand\csname Room\theRoomCount\endcsname{#1}%
}
\NewDocumentCommand\buildrows{}{%
\newbool{myBool}%
\booltrue{myBool}%
\newcounter{rownum}%
\whileboolexpr{myBool}{%
\stepcounter{rownum}%
\ifcsdef{Room\therownum}%
{\csname Room\therownum\endcsname}%
{\boolfalse{myBool}}%
}%
}
\begin{document}
\Room(C244)
\begin{tabular}{l}
\buildrows{}
\end{tabular}
\end{document}