Joel via ntg-context schrieb am 09.01.2022 um 15:16:
Is there a way for a macro to check the previous value of #1, the last
time that same macro was called?
Here is a minimum working example, pretending that `\previousvalue` is
equal to #1 from the last time the same macro was called:
[...]
To check is the current value differs from the last one you need a temp
macro where you store the current value at the end of your command to
check it in the next call.
\let\previousmymacro\empty
\define[1]\mymacro
{\edef\currentmymacro{#1}%
\ifx\previousmymacro\currentmymacro
same as last time
\else
it is different from last time
\fi
\let\previousmymacro\currentmymacro}
\starttext
\startlines
cat: \mymacro{cat}
cat: \mymacro{cat}
mouse: \mymacro{mouse}
mouse: \mymacro{mouse}
cat: \mymacro{cat}
\stoplines
\stoptext
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________