When there is \directlua{x = 25} one can say \edef\rgf{\directlua{tex.sprint(x)}}, but when x was never created by \directlua{x = 25}, \directlua{tex.sprint(x)} will fail. Thus something like \@ifundefined{x}{x undefined}{x defined} would be nice. How does one "say this in Lua", please?
Asked
Active
Viewed 191 times
8
Stephen
- 14,890
-
3May be you 'd try reading some general lua programming documentation first. – خالد حسني Nov 03 '11 at 14:28
-
@KhaledHosny: I tried but did not find it there. Any suggestion for better lua-documentation? – Stephen Nov 03 '11 at 17:56
1 Answers
12
You can do this:
\directlua{tex.sprint( x or 42 ) }
or perhaps
\directlua{
if x then
tex.sprint(x)
% else
% do something else
end
}
topskip
- 37,020
-
1
-
Thanks, it works! (Upvoted & accepted.) Also your answer to the other question is enlightening, but unfortunately with that question title one does not find it without being told that it is there. – Stephen Nov 03 '11 at 17:52