From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/111881 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jeong Dal Newsgroups: gmane.comp.tex.context Subject: Re: Delivering the value of a variable in MetaFun to ConTeXt Date: Thu, 24 Jun 2021 11:33:34 +0900 Message-ID: <586CFBE5-4AFC-48C9-A7BB-37159C1CA5A6@me.com> References: <1d2d97dc-0095-6547-4625-1a264cc455b3@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Content-Type: multipart/mixed; boundary="===============2986026962669565173==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30731"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mailing list for ConTeXt users To: Hans Hagen Original-X-From: ntg-context-bounces@ntg.nl Thu Jun 24 04:34:24 2021 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 1lwFCC-0007qC-04 for gctc-ntg-context-518@m.gmane-mx.org; Thu, 24 Jun 2021 04:34:24 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id A9537284A8E; Thu, 24 Jun 2021 04:33:47 +0200 (CEST) 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 zbxa6onktLVH; Thu, 24 Jun 2021 04:33:45 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C7461284B91; Thu, 24 Jun 2021 04:33:45 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8908C284B8C for ; Thu, 24 Jun 2021 04:33:44 +0200 (CEST) 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 OHQP7S71d4yH for ; Thu, 24 Jun 2021 04:33:43 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=17.58.6.49; helo=pv50p00im-ztdg10012101.me.com; envelope-from=haksan@me.com; receiver= Original-Received: from pv50p00im-ztdg10012101.me.com (pv50p00im-ztdg10012101.me.com [17.58.6.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 62116284A8E for ; Thu, 24 Jun 2021 04:33:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1624502021; bh=YrFysOjZEwR9o/knGowYXUJWkhgqmZIpl5KNcVDBm8E=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=F77yS3/9HSjpMVb//0OgsTS8iiUR08I+wgD3Ug8XZ5/WTiaRsPMfI0VcS6AlZtSKJ urze9gQORC8eZ2TYd07XInL3G7zzAh/fLew7xORbGp/OR5ZDXDZ6D5UuDJiAohAtt6 u2Ed7OaA2fGuEIKuJ/Qi0OudTal+JET9j/AIz3L5Ydh/jBitD1aVgmtP2rNiQtFFLm lJL3p+Q9Qn3vSZjaY8+hL4GwXHmVO29Drr9kHB2BZipve83EO7U1Pa45PeHJlcqJcD J+Ij4ZC+PMt4vvP8V7ipB5v8oby+FSxy6cMDmZBZ9WlIONlr/LHLqdJcnMwfdNR4vH sxuYM/mTbTBtQ== Original-Received: from smtpclient.apple (unknown [222.232.154.22]) by pv50p00im-ztdg10012101.me.com (Postfix) with ESMTPSA id E4FDA840260; Thu, 24 Jun 2021 02:33:38 +0000 (UTC) In-Reply-To: <1d2d97dc-0095-6547-4625-1a264cc455b3@xs4all.nl> X-Mailer: Apple Mail (2.3654.100.0.2.22) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-23_14:2021-06-23, 2021-06-23 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=943 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2106240013 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:111881 Archived-At: --===============2986026962669565173== Content-Type: multipart/alternative; boundary="Apple-Mail=_EF8EB74B-BD4E-4017-8243-842DEC1C872E" --Apple-Mail=_EF8EB74B-BD4E-4017-8243-842DEC1C872E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Dear Hans, Your code works fine. > \starttext >=20 > \startMPcode > numeric maxCount; > maxCount :=3D 10; > setglobalmacro("MyMacro",decial maxCount); > setglobalcount("MyCount",maxCount); > \stopMPcode >=20 >=20 > \dorecurse{\MyMacro}{It is \recurselevel. }\par > \dorecurse{\MyCount}{It is \recurselevel. }\par >=20 > \stoptext I applied your method to my code as following.=20 \newcount\udCount %%% add count \startMPinitializations%{UDBasic} pair A,B,C,D; pair E, F, G, H; path p,q; numeric ang,maxNum; numeric n; %AM Added u:=3D1in; A=3D(.95*TextWidth,u); B=3D(0,u); C=3D(0,0); D=3D(.95*TextWidth,0); p :=3D A--B--C--D; q :=3D (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle; z0=3D(.1u,0); =20 vardef nextPt (expr M,N) =3D=20 if ypart(N) =3D 0:=20 H :=3D whatever[N, N + dir(.5*angle(M-N))*u] =3D whatever[A,B]; else: H :=3D whatever[N, N + dir(.5*angle(M-N))*u] =3D whatever[C,D]; fi; H enddef; def grayUD(expr i) =3D draw G -- if ypart(B)=3Dypart(G): B -- C else: C -- B fi --z[i]; filldraw z[i]+2*(G-z[i])*u -- z[i] -- z[i+1] -- z[i+1]+(G-z[i])*u = -- cycle withcolor .75white;=20 draw G -- z[i+1] dashed evenly; draw z[0] for k=3D0 upto i: --z[k] endfor dashed evenly; clip currentpicture to q; enddef; def linesUD(expr i) =3D draw p; draw z0 for k=3D0 upto i+1: --z[k] endfor dashed evenly; % AM: removed. Set in in the main code % setbounds currentpicture to boundingbox q; enddef; ang :=3D 40; z[1] =3D whatever[z[0], z[0]+dir(ang)*u] =3D whatever[A,B]; % AM: Changed next line from G to z[-1] z[-1] =3D whatever[z[0], z[0]+dir(2*ang)*u] =3D whatever[A,B]; for k =3D 2 upto 20: z[k] =3D nextPt(z[k-2],z[k-1]); maxNum :=3D k; exitif xpart(z[k]) > TextWidth; endfor; maxNum :=3D maxNum-1; setglobalmacro("udMacro",decimal maxNum); %%% define udMacro and = udCount setglobalcount("udCount",maxNum); \stopMPinitializations \startuseMPgraphic{foldUD}{num} numeric n; n :=3D \MPvar{num}-1; G :=3D z[n-1]; grayUD(n); \stopuseMPgraphic \startuseMPgraphic{dotLines}{num} numeric n; n :=3D \MPvar{num}-1; linesUD(n); \stopuseMPgraphic \setupinteraction[state=3Dstart] \usemodule[animation] \starttext %\startanimation[menu=3Dyes] %{ \dorecurse{\udCount} {\useMPgraphic{foldUD}{num=3D\recurselevel}} {\useMPgraphic{dotLines}{num=3D\recurselevel}} %} %\stopanimation \stoptext 1. Using =E2=80=9CudCount=E2=80=9D doesn=E2=80=99t issue error message, = but it draws the path p only. 2. Using =E2=80=9CudMacro=E2=80=9D issue the error message. Is there anything that I miss? Best regards, Dalyoung ********** tex error > tex error on line 75 in file = /Users/graph/Library/Mobile = Documents/com~apple~CloudDocs/texMain/funmath/foldBandMPnew.tex: = Undefined control sequence \udMacro=20 =20 \dorecurse #1->\ifcase #1 \relax \expandafter \gobbletwoarguments \or \expandafter = \syst_helpers_recurse_y \else \expandafter \syst_helpers_recurse_x \fi = {#1} \dorecurse{\udMacro} =20 65 numeric n; 66 n :=3D \MPvar{num}-1; 67 linesUD(n); 68 \stopuseMPgraphic 69 =20 70 \setupinteraction[state=3Dstart] 71 \usemodule[animation] 72 \starttext 73 %\startanimation[menu=3Dyes] 74 %{ 75 >> \dorecurse{\udMacro} 76 {\useMPgraphic{foldUD}{num=3D\recurselevel}} 77 {\useMPgraphic{dotLines}{num=3D\recurselevel}} 78 %} =20= --Apple-Mail=_EF8EB74B-BD4E-4017-8243-842DEC1C872E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Dear = Hans,

Your code = works fine.

\starttext

\startMPcode
   numeric maxCount;
   maxCount :=3D 10;
   setglobalmacro("MyMacro",decial = maxCount);
   setglobalcount("MyCount",maxCount);\stopMPcode


\dorecurse{\MyMacro}{It is \recurselevel. }\par
\dorecurse{\MyCount}{It is \recurselevel. }\par

\stoptext

I applied your method to my code as = following. 

\newcount\udCount %%% add count
\startMPinitializations%{UDBasic}
pair A,B,C,D;
pair E, F, G, H;
path = p,q;
numeric ang,maxNum;

numeric n; %AM Added

u:=3D1in;
A=3D(.95*TextWidth,u); B=3D(0,u); = C=3D(0,0); D=3D(.95*TextWidth,0);
p :=3D A--B--C--D;
= q :=3D (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle;
z0=3D(.1u,0);
= vardef= nextPt (expr = M,N) =3D
= if = ypart(N) = =3D 0:
H :=3D whatever[N, N + dir(.5*angle(M-N))*u] = =3D whatever[A,B];
else:
H :=3D whatever[N, N + dir(.5*angle(M-N))*u] = =3D whatever[C,D];
fi;
= H
enddef;

= def = grayUD(expr = i) =3D
draw G = -- = if = ypart(B)=3Dypart(G): = B -- = C else: = C -- = B fi = --z[i];
filldraw z[i]+2*(G-z[i])*u = -- = z[i] -- z[i+1] = -- = z[i+1]+(G-z[i])*u = -- = cycle = withcolor .75white;
draw G -- z[i+1] = dashed= evenly;
draw z[0] = for = k=3D0 upto i: --z[k] = endfor= dashed evenly;
clip currentpicture to q;
= enddef;

def = linesUD(expr = i) =3D
draw = p;
draw z0 for k=3D0 = upto = i+1: --z[k] = endfor= dashed evenly;

= % AM: removed. Set in in = the main code
% setbounds currentpicture to boundingbox = q;
enddef;

ang :=3D 40;
z[1] = =3D whatever[z[0], = z[0]+dir(ang)*u] = =3D whatever[A,B];

% AM: Changed next line from G to = z[-1]
z[-1] = =3D whatever[z[0], = z[0]+dir(2*ang)*u] = =3D whatever[A,B];
for k =3D 2 upto 20:
z[k] =3D = nextPt(z[k-2],z[k-1]);
maxNum :=3D k;
= exitif xpart(z[k]) = > = TextWidth;
endfor;
maxNum :=3D maxNum-1;
setglobalmacro("udMacro",decimal maxNum); %%% define udMacro and udCount
= setglobalcount("udCount",maxNum);

\stopMPinitializations

\startuseMPgraphic{foldUD}{num}
numeric n;
n :=3D = \MPvar{num}-1;
G :=3D z[n-1];
grayUD(n);
\stopuseMPgraphic
\startuseMPgraphic{dotLines}{num}
numeric n;
n :=3D = \MPvar{num}-1;
linesUD(n);
\stopuseMPgraphic

\setupinteraction[state=3Dstart]
\usemodule[animation]
\starttext
%\startanimation[menu=3Dyes]
%{
\dorecurse{\udCount}
{\useMPgraphic{foldUD}{num=3D\recurselevel}}
{\useMPgraphic{dotLines}{num=3D\recurselevel}}
%}
%\stopanimation
\stoptext

1. Using =E2=80=9CudCount=E2=80=9D = doesn=E2=80=99t issue error message, but it draws the path p = only.
2. Using =E2=80=9CudMacro=E2=80=9D issue the = error message.

Is there anything that I miss?

Best regards,

Dalyoung

**********
tex error       > tex error on line 75 in = file /Users/graph/Library/Mobile = Documents/com~apple~CloudDocs/texMain/funmath/foldBandMPnew.tex: = Undefined control sequence

<argument> \udMacro 
  =   
<macro> \dorecurse = #1->\ifcase #1
    \relax \expandafter = \gobbletwoarguments \or \expandafter \syst_helpers_recurse_y \else = \expandafter \syst_helpers_recurse_x \fi {#1}
<line 3.75> \dorecurse{\udMacro}
    
65     =    numeric n;
66       =  n :=3D \MPvar{num}-1;
67       =  linesUD(n);
68     = \stopuseMPgraphic
69     
70     \setupinteraction[state=3Dstart]
71     \usemodule[animation]
72 =     \starttext
73     = %\startanimation[menu=3Dyes]
74     = %{
75 >>  \dorecurse{\udMacro}
76     =  {\useMPgraphic{foldUD}{num=3D\recurselevel}}
77=     =  {\useMPgraphic{dotLines}{num=3D\recurselevel}}
78     %}
 
= --Apple-Mail=_EF8EB74B-BD4E-4017-8243-842DEC1C872E-- --===============2986026962669565173== 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== --===============2986026962669565173==--