![](https://secure.gravatar.com/avatar/85958064893895913ad64d02e0d5cb11.jpg?s=120&d=mm&r=g)
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.