Back HomeBack to DocumentsBack to D-I-E-S-E-LYou are here
The Macro Evaluation Sequence


The Macro Evaluation Sequence

VG-Wort Access-ZählmarkeThe evaluation sequence of DIESEL expressions in menu macros is difficult to understand. It is however essential for a correct macro evaluation. Let's look at the following macro:

[Test]snapang;0;_text;+
$M=$(getvar,insbase);+
'snapang;45;+
20;+
$(getvar,snapang);+
Insbase;

How translates this line to the actual macro code AutoCAD runs? The first characters to the right of the menu label are sent to the command processor, i.e. SNAPANG is set to 0 and the text command starts. As soon as the $M= sequence is encountered, the DIESEL interpreter processes the rest of the macro. The DIESEL input string is:

$(getvar,insbase);+
'snapang;45;+
20;+
$(getvar,snapang);+
Insbase;

The DIESEL result string is

0,0,0;+
'snapang;45;20;+
0;+
Insbase;

These characters are sent to the command interpreter. Note that the current SNAPANG value is used, of course. If you want the macro to use the modified SNAPANG value, the first try is to add another "$M=" to the macro:

[Test]snapang;0;_text;+
$M=$(getvar,insbase);+
'snapang;45;+
20;+
$M=$(getvar,snapang);+
Insbase;

The DIESEL input string now is:

$(getvar,insbase);+
'snapang;45;+
20;+
$M=$(getvar,snapang);+
Insbase;

Unfortunately this translates to:

0,0,0;+
'snapang;45;+
20;+
$M=0;+
Insbase;

Which does no good, either.
The correct solution is to also add a pair of quotes. This keeps the inner DIESEL expression from evaluation:

[Test]snapang;0;_text;+
$M=$(getvar,insbase);+
'snapang;45;+
20;+
"$M=$(getvar,snapang)";+
Insbase;

The DIESEL input string is now:

$(getvar,insbase);+
'snapang;45;+
20;+
"$M=$(getvar,snapang)";+
Insbase;

The DIESEL result string is:

0,0,0;+
'snapang;45;+
20;+
$M=$(getvar,snapang);+
Insbase;

Note that the second DIESEL expression has not been evaluated, but is copied literally to the macro string. Now the menu interpreter continues. It sends the 0,0,0 point to the text prompt. Next the SNAPANG value is set. The text command continues and receives the text height value "20".
Another "$M=" is encountered. The DIESEL interpreter is called again, now with this input string:

$(getvar,snapang);+
Insbase;

The result is

0.78539816;
INSBASE;

Even though this may not be the command sequence you intended to run, the new SNAPANG value is used, however.

This is a shareware document. What is a shareware document? Did this article help you earn some money? Then give something back! Help creating shareware documents by donating something to the author:


Contact CR/LF GmbH

© 2000-2011 by CR/LF GmbH, Essen/Germany. All rights reserved.
No part of this document may be reproduced or published without written consent by CR/LF GmbH.
Last modification: 01.04.2011