Hi, I just tried to build my own object in metaobj but for some reason I cannot figure out it does not work. I tried the example from the metaobj manual in a tex document (it works in a metapost file): \startuseMPgraphic{objecttest} vardef newSegment@#= assignObj(@#,"Segment"); ObjPoint a,b; ObjCode "@#b-@#a=(1cm,2cm)"; enddef; \stopuseMPgraphic When processing this with context (MkIV) I get ! Illegal parameter number in definition of \@MPG@objecttest. <to be read again> = <argument> vardef newSegment@##= assignObj(@##,"Segment"); ObjPoint a,b; Ob... \dostartuseMPgraphic ...leuseMPgraphic {#1}{#2}{#3 }} l.7 \stopuseMPgraphic My first wild guess is that it has something to do with the "evil" @-symbol. But even if this is the case I don't know what to do to fix this. Any help appreciated and thank you very much in advance. Stefan.
On 13-7-2010 6:01, Stefan Müller wrote:
Hi,
I just tried to build my own object in metaobj but for some reason I cannot figure out it does not work. I tried the example from the metaobj manual in a tex document (it works in a metapost file):
\startuseMPgraphic{objecttest} vardef newSegment@#= assignObj(@#,"Segment"); ObjPoint a,b; ObjCode "@#b-@#a=(1cm,2cm)"; enddef; \stopuseMPgraphic
When processing this with context (MkIV) I get
! Illegal parameter number in definition of \@MPG@objecttest. <to be read again> = <argument> vardef newSegment@##= assignObj(@##,"Segment"); ObjPoint a,b; Ob... \dostartuseMPgraphic ...leuseMPgraphic {#1}{#2}{#3 }} l.7 \stopuseMPgraphic
My first wild guess is that it has something to do with the "evil" @-symbol. But even if this is the case I don't know what to do to fix this. Any help appreciated and thank you very much in advance.
no, more with # being special to tex's parser \string# or \# will probably do ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 13.07.2010 21:03, Hans Hagen wrote:
On 13-7-2010 6:01, Stefan Müller wrote:
Hi,
I just tried to build my own object in metaobj but for some reason I cannot figure out it does not work. I tried the example from the metaobj manual in a tex document (it works in a metapost file):
\startuseMPgraphic{objecttest} vardef newSegment@#= assignObj(@#,"Segment"); ObjPoint a,b; ObjCode "@#b-@#a=(1cm,2cm)"; enddef; \stopuseMPgraphic
When processing this with context (MkIV) I get
! Illegal parameter number in definition of \@MPG@objecttest. <to be read again> = <argument> vardef newSegment@##= assignObj(@##,"Segment"); ObjPoint a,b; Ob... \dostartuseMPgraphic ...leuseMPgraphic {#1}{#2}{#3 }} l.7 \stopuseMPgraphic
My first wild guess is that it has something to do with the "evil" @-symbol. But even if this is the case I don't know what to do to fix this. Any help appreciated and thank you very much in advance.
no, more with # being special to tex's parser
\string# or \# will probably do
Thank you Hans for the fast answer. Adding \string in front of every # led to basically the same error message (only difference: "@\sting ##" instead of "@##"). When using \# instead of # in the vardef the small example from above works (even with \placefigure added). But there is still a problem: \starttext \startuseMPgraphic{objecttest} vardef newSegment@\#= assignObj(@\#,"Segment"); ObjPoint a,b; ObjCode "@\#b-@\#a=(1cm,2cm)"; enddef; newSegment.s; % create an instance \stopuseMPgraphic \placefigure[here][fig:objecttest]{My object}{\useMPgraphic{objecttest}} \stoptext now produces the metapost error ! Isolated expression. <to be read again> ( newSegment->begingroup.assignObj( (SUFFIX2),"Segment");ObjPoint.a,b;ObjCode"@... <to be read again> ; <*> ... "@#b-@#a=(1cm,2cm)"; enddef; newSegment.s; Without \placefigure there is no error at all. (Maybe then metapost doesn't even run?) And I again have no clue what's going on. Thanks for your help in advance. Stefan.
On Wed, Jul 14, 2010 at 7:16 AM, Stefan Müller
On 13.07.2010 21:03, Hans Hagen wrote:
On 13-7-2010 6:01, Stefan Müller wrote:
Hi,
I just tried to build my own object in metaobj but for some reason I cannot figure out it does not work. I tried the example from the metaobj manual in a tex document (it works in a metapost file):
\startuseMPgraphic{objecttest} vardef newSegment@#= assignObj(@#,"Segment"); ObjPoint a,b; ObjCode "@#b-@#a=(1cm,2cm)"; enddef; \stopuseMPgraphic
Can you post a complete metapost file that gives some output.I tried the following mp file: input metaobj; vardef newSegment@#= assignObj(@#,"Segment"); ObjPoint a,b; ObjCode "@#b-@#a=(1cm,2cm)"; enddef; beginfig(1) ; newSegment.s; % create an instance endfig ; end;
but running it through metapost gives me an empty file: %!PS %%BoundingBox: 0 0 0 0 %%HiResBoundingBox: 0 0 0 0 %%Creator: MetaPost 1.208 %%CreationDate: 2010.07.15:0119 %%Pages: 1 %%BeginProlog %%EndProlog %%Page: 1 1 showpage %%EOF Aditya
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Stefan Müller