Let's say I have some macro (\iPrint in the MWE) that internally uses active characters to interpret its argument:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begingroup
\lccode`\~=`\|
\lowercase{\endgroup
\def~#1~{\textbf{#1}}%
}
\def\iPrint{%
\begingroup
\catcode`\|=\active
\iPrintX
}
\def\iPrintX#1{%
#1
\endgroup
}
\begin{document}
\def\temp{This |doesn't work|, though :-(}
\begin{itemize}
\item \iPrint{This |works pretty| well!}
\item \iPrint{\temp}
\end{itemize}
\end{document}
This yields:

AFAIU the issue, catcodes are assigned at definition time of a macro: When \temp is defined, | is not active. However, is there something I can do within \iPrint to make it active anyway? Some sort of recoding the argument with the current catcodes?
\noexpandat the end of the argument to\scantokenscan be replaced by\relax, or by\empty. It's only effect is that the last line of the virtual file built by\scantokensends with a control word, hence a newline doesn't produce a space. As it is, your\noexpandacts on\endgroup, which luckily does nothing bad. – Bruno Le Floch Jan 29 '12 at 00:10