Thanks to Henri for the answer. To I admit, I thought it a bit technically that it would not be technically possible. At least I know why I was tearing my teeth while trying to test ... One more thanx. Jaroslav Hajtmar
Dne 22.07.17 3:58, ntg-context za uživatele Henri <ntg-context-boun...@ntg.nl za uživatele henrime...@gmail.com> napsal(a): On Fri, 2017-07-21 at 11:25 +0000, Jaroslav Hajtmar wrote: > Hello ConTeXist. > Is there any way to evaluate of contents of two macros as I am showing in my minimal example? > I know, that problem is in expansion, but I dont know to resolve it. > My minimal example consist of piece lua code, because I am solving my problem in mixed codes (TeX > & Lua) Something similar has been asked before and it is not possible. The interfaces.definecommand function defines a new macro using \protected\def. To compare as equal in a \doif context, both operands have to _expand_ to the same thing (here 123). Here \mymacro is not expandable and thus only \doifelse{\mymacro}{\mymacro} will ever compare true. Furthermore, scanning for optional arguments (i.e. [...]) is inherently non-expandable. To get something expandable you must at least switch to mandatory arguments (i.e. {...}). Still, using interfaces.definecommand will still not be possible. I believe that scanning arguments is better done on the macro level than in Lua, but that's just my opinion. > Thanx for help. > Jaroslav Hajtmar > > > \starttext > > \startluacode > interfaces.definecommand ("domymacro", { > arguments = { { "option", "string" } }, > macro = function (opt_1) > if #opt_1>0 then > context(opt_1) > else > context("123") > end > end > }) > interfaces.definecommand("mymacro", { > macro = function () > context.dosingleempty() > context["domymacro"]() > end > }) > \stopluacode > > \def\myothermacro{123} > > \hairline > > \mymacro[123] > > \mymacro > > \myothermacro > > \hairline > > \doifelse{\mymacro}{\mymacro[123]}{equal content}{not equal content} > > \doifsamestringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content} > > \doifinstringelse{\mymacro}{\mymacro[123]}{equal content}{not equal content} > > \doifincsnameelse{\mymacro}{\mymacro[123]}{equal content}{not equal content} > > > \hairline > > \doifelse{\mymacro}{\myothermacro}{equal content}{not equal content} > > \doifsamestringelse{\mymacro}{\myothermacro}{equal content}{not equal content} > > \doifinstringelse{\mymacro}{\myothermacro}{equal content}{not equal content} > > \doifincsnameelse{\mymacro}{\myothermacro}{equal content}{not equal content} > > > > \stoptext > > > > ___________________________________________________________________________________ > If your question is of interest to others as well, please add an entry to the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________