title: LaTeX Immediate Evaluation
body: <p>I'm trying to write a command in LaTeX that takes a string such as 8:00A and converts it into the number of minutes, as part of a script to draw a class schedule using TikZ.  However, I'm running into some issues - it seems that LaTeX doesn't actually evaluate the contents of a command.</p>
  
  <p>My command is currently:</p>
  
  <pre><code>\newcommand{\timetominutes}[1]{
    \IfSubStr{#1}{P}{720}{0}+\IfSubStr{#1}{P}{\StrBetween{#1}{:}{P}}{\StrBetween{#1}{:}{A}}+60*\StrBefore{#1}{:}
  }
  </code></pre>
  
  <p>If you print out the text from it, it will correctly calculate the number of minutes from midnight.  However, if used inside another function, it becomes apparent that it doesn't <em>actually</em> run any of those commands - it merely returns text including those commands.  So if I write:</p>
  
  <pre><code>\myfunc{\timetominutes{8:00A}}
  </code></pre>
  
  <p>Instead of <code>\myfunc</code> seeing something useful like <code>0+00+60*8</code>, it sees <code>\IfSubStr{8:00A}{P}{720}{0}+\IfSubStr{8:00A}{P}{\StrBetween{8:00A}{:}{P}}{\StrBetween{8:00A}{:}{A}}+60*\StrBefore{8:00A}{:}</code>.  This is absolutely useless to me and I can't seen to find a way to force LaTeX to execute subcommands before the main one.  I assume there's a way to do it, but LaTeX documentation is scarce and I can't seem to find anything.</p>
  
  <p>Alternatively, if there's a way to get LaTeX to stop complaining about too many <code>}</code>s (when I have the correct number), that could work.</p>