On Aug 28, 2008, at 9:45 AM, Hans Hagen wrote:
Hans, thanks a lot for your reply. Amazing - the lua code is so simple
that even I can understand it! I'm certain to use it later; for the
time being, I want to remain compatible for mkii and XeTeX as well.
> \startluacode
> document.mymodule = document.mymodule or { }
>
> function document.mymodule.checkdimen(str)
> return (str:find("%a%a$") and str) or (str .. "mm")
> end
> \stopluacode
>
> \ctxlua{document.mymodule.checkdimen("#1")}
>
> or more fancy:
>
> function document.mymodule.checkdimen(str)
> if not str:find("%a%a$") then
> str = str .. "mm"
> ctx.writestatus("mymodule","you forgot a dimension unit, so I
> made it up for you: %s",str)
> end
> return str
> end
>
> for mkii you can use \doifdimensionelse (it reminds me to implement
> that
> in mkiv)
Hey, I WAS using \doifdimensionelse and \doifnumberelse! :-) And it
appears to be working in mkiv as well! I found out the error in my
code (it was too complex, and I was overwriting a variable with the
same name; it looks like Metapost assigns "sp" as default unit to
\MPvar). Problem solved, but it took me half a day...
All best
Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________