Changes

Jump to navigation Jump to search
no edit summary
\getfirstcharacter {string}
</texcode>
 
== Problems with expansion ==
Be aware that <code>\processaction</code> is not fully expandable. This means that the following won't work.
 
<texcode>
\def\MyMacro#1{\processaction[#1][a=>\a,b=>\b]}
\edef\x{\MyMacro{a}}
</texcode>
 
A solution in MkIV proposed by Taco on [[http://archive.contextgarden.net/message/20100513.073030.d6d1fa3a.en.html 2010-05-13]] is to define <code>\MyMacro</code> as follows
 
<texcode>
\def\MyMacro#1{\directlua{
local known = {a = '\a', b = '\b'}
tex.sprint(known['#1'] or '\a')}}
</texcode>
 
Another way that should work in MkII too, but doesn't cope with unknown values:
 
<texcode>
\getparameters[MyMacro:][a=\a,b=\b]
\def\MyMacro#1{\csname MyMacro:#1\endcsname}
</texcode>
 
< '''Prev:''' [[System Macros/Loops and Recursion|Loops & Recusion]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Comma Separated Lists|Comma Separated Lists]] >
3

edits

Navigation menu