On Tue, 24 Sep 2002, Stefan Svensson wrote:

> I would like to simplify this with a macro that iterates over a string
> with all notes in the scale ({cd_efg'_ab}) and adds the corresponding
> numbers below, perhaps from a string like {12{\flt3}45{\flt6}{\flt7}}.

This looks like beeing a job for \futurelet: \futurelet\a\b<...> sets \a
to the first token of <...> and executes then \b. You may set up a loop
using this control sequence by iteration:

1 append an end character to the string
2 read the first character into a macro
3 if it is not the end character
  - process it
  - set a temporary macro to the operations 2-4
  else
  - drop the end character
  - set the temporary macro to a void action
4 put the temporary macro

this should look like follows (not tested)

\def\processtoken#1{whatever you want to do with the single tokens}
\def\setend#1{#1-}% sets an endmark (`-`) behind the string
\def\check{% checks one token
  \if\temp-\let\next\relax
  \else\processtoken\temp\let\next\iterate
  \fi
  \next
}
\def\iterate{\futurelet\temp\check}
\def\processstring#1{\expandafter\iterate\setend{#1}}


happy hacking
  Bernhard

_______________________________________________
TeX-music mailing list
[EMAIL PROTECTED]
http://sunsite.dk/mailman/listinfo/tex-music

Reply via email to