From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114101 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joel via ntg-context Newsgroups: gmane.comp.tex.context Subject: How to let a macro check the previous value of #1 the last time the same macro was called? Date: Sun, 9 Jan 2022 14:16:37 +0000 (UTC) Message-ID: <1050338993.1893942.1641737797345@mail.yahoo.com> References: <1050338993.1893942.1641737797345.ref@mail.yahoo.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8973904509677467789==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36724"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Joel To: "ntg-context@ntg.nl" Original-X-From: ntg-context-bounces@ntg.nl Sun Jan 09 15:17:23 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6Z0c-0009F1-Qb for gctc-ntg-context-518@m.gmane-mx.org; Sun, 09 Jan 2022 15:17:22 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1AAE02894E9; Sun, 9 Jan 2022 15:16:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 67x1CRnCUEVf; Sun, 9 Jan 2022 15:16:46 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 41263288FB8; Sun, 9 Jan 2022 15:16:46 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 15422288FB8 for ; Sun, 9 Jan 2022 15:16:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C09yZPSd7kV4 for ; Sun, 9 Jan 2022 15:16:43 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=74.6.129.123; helo=sonic309-13.consmr.mail.bf2.yahoo.com; envelope-from=uaru99@yahoo.com; receiver= Original-Received: from sonic309-13.consmr.mail.bf2.yahoo.com (sonic309-13.consmr.mail.bf2.yahoo.com [74.6.129.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 0BFE32815BF for ; Sun, 9 Jan 2022 15:16:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1641737801; bh=Niy/PsZ3wi77tv7s29GvU/R9ZVx7Sl9dsC3RKziyzpw=; h=Date:From:To:Subject:References:From:Subject:Reply-To; b=VQDbgwe1d7OodRKuI0Fy8YhaJMwwTm/jqaba2SM1xkzIuULMRYz/8n36niWb84Q1Me404B4siSdiLTwqZSF7ECAPQewsvr+iVEyxVdTslnj54Lj1r4/JEbL8GI2uLv79RZ7D4iNQuWnzDlL+En6Jzss9Mzgp+B1v/htaY1Kb+6IDCT0pMR8sV+ZpGgZWmz2voQcBFNUsLGLfc9d5GvyodjRkQyycW5Bd0WBMKy3fkY6wqWjrOvj+xHLREz/r9sxifIXdaWGd61MHfbnMV/mRhlZ3EZX9ny4DW+I88ZOjtTDZBkjuRTsaQwROwZIiuKdQ0V2tkr86x2B633PddAAd3g== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1641737801; bh=/WMLTzBhv5jqUlHwNXpbXwos16pPz3mOENGinZxx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oZjLtLoRpwFDccbozoc1YwIYmPv2NtXox5cDY_s7SnL.._YCskHqSmLsR6XCh.aC BqfhPbTXNJk4BU_KmzVFHnjYyyotniw4xfJ9u7A4DnvTRntbHR4bZMDSeviwf.JXX9gOpVqG8EOy MJfg6cUUZOjh66vYTcU3PYXp_LigaJTj_G3PdxgJpG X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.bf2.yahoo.com with HTTP; Sun, 9 Jan 2022 14:16:41 +0000 X-Mailer: WebService/1.1.19551 YMailNorrin X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:114101 Archived-At: --===============8973904509677467789== Content-Type: multipart/alternative; boundary="----=_Part_1893941_302250505.1641737797344" ------=_Part_1893941_302250505.1641737797344 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 equa= l to #1 from the last time the same macro was called: =C2=A0=C2=A0=C2=A0 \define[1]\mymacro{ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \if\previousvalue=3D#1 =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0same as last time =C2=A0=C2=A0 =C2=A0\else =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0it is different from last time =C2=A0=C2=A0 =C2=A0\fi =C2=A0=C2=A0=C2=A0 } \starttext =C2=A0=C2=A0=C2=A0 \mymacro{cat} =C2=A0=C2=A0=C2=A0 \mymacro{cat} =C2=A0=C2=A0=C2=A0 \mymacro{mouse} =C2=A0=C2=A0=C2=A0 \mymacro{mouse} =C2=A0=C2=A0=C2=A0 \mymacro{cat} \stoptext This would print: =C2=A0=C2=A0=C2=A0 it is different from last time <--it was never called pr= eviously =C2=A0=C2=A0=C2=A0 same as last time =C2=A0=C2=A0=C2=A0 it is different from last time =C2=A0=C2=A0=C2=A0 same as last time =C2=A0=C2=A0=C2=A0 it is different from last time --Joel ------=_Part_1893941_302250505.1641737797344 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
= 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, pret= ending that `\previousvalue` is equal to #1 from the last time the same mac= ro was called:

    \define[1]\mymacro{
  = ;      \if\previousvalue=3D#1
   &nbs= p;    same as last time
    \else
 = ;       it is different from last time
 &n= bsp;  \fi
    }

\starttext

  = ;  \mymacro{cat}
    \mymacro{cat}
  &n= bsp; \mymacro{mouse}
    \mymacro{mouse}
  &= nbsp; \mymacro{cat}

\stoptext

This would print:

 =    it is different from last time <--it was never called previ= ously
    same as last time
    it is d= ifferent from last time
    same as last time
 &n= bsp;  it is different from last time

--Joel

------=_Part_1893941_302250505.1641737797344-- --===============8973904509677467789== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============8973904509677467789==--