I am creating a class that I want to use for creating my own worksheets. As such, I want each course that I teach to have its own information file, stored in the file , which, in the assignment, I can access by using a command such as \course{\<course-number-term>}.
Thus, in my class preamble file, I have the following code for the course:
\newcommand*{\course}[1]{\gdef\@course{#1}}
\input{\@course}
I know that the first line works for other text related things I am doing, and that the second line works for other static files in the same folder as my <course-number-term>.tex file, so each of these commands works independently, but not together, since I get the error
! undefined control sequence.
\@course -> \course
l.42 \input{\@course}
Is there a way to pass a variable into the \input command, or am I doomed to a lack of flexibility?
——————EDIT——————
Thank you everyone for the comments and solutions. I should have mentioned, I'm mostly using the information from the course tex file INSIDE the preamble—so, doing anything that inputs it after the \begin{document} doesn't quite cut it.

\newcommand{\course}and\input{\@course}you need to use\course{whatever}to set some value to\@course, otherwise it will be undefined, raising the error you see – Phelype Oleinik Sep 27 '19 at 18:43\makeatletter...\makeatotherpair? – Werner Sep 27 '19 at 18:50\expandafter\gdef\csname @course\endcsname...– John Kormylo Sep 27 '19 at 18:57\AtBeginDocument{\input{\@course}}in your cls. – Ulrike Fischer Sep 27 '19 at 18:57\@course -> \courseso\@coursedefined to expand to\coursewhich does not match the code that you show. the error is unrelated to\input. Please edit the question to provide a test that people can run to debug the error. – David Carlisle Sep 27 '19 at 20:00