DMDX Help.

Macro Set Keyword

<macro set name = expression>

macro name designators:
c (a single ASCII char)
.macroname.

   Rounding out my wish list of features since forever is the macro set operator added in version 4.3.0.0. that sets a macro to the string representing the result of the expression.  This is really handy if there's some keyword that you want a parameter set from an expression and DMDX doesn't allow it otherwise (see the macro and other following sections of introduction for more examples).  So the following for instance results in counter 49 getting assigned "49":

~1 <macro set .body. = 7*7> <set c49 = `.body.>;

   If for some perverse reason you wanted to use the legacy tilde macro lead in the solution is to use two items.  Note they're skip display items (that confusingly use tilde correct response indicators, sorry about that) so they execute almost as fast as one does:

~1 <macro set .body. = 7*7>;
~1
<set c49 = ~.body.>;


Macro Fixed Point Set Keyword

<macro fxpset N name = expression>

macro name designators:
c (a single ASCII char)
.macroname.

   Back in the dark ages when I first added the expression evaluator to DMDX there was no call for floating point capability at all, indeed not all processors had floating point units so using them was sloooow, however as DMDX has evolved there are now several cases where they're used, screen coordinates can now be between zero and one and both font and bitmap multipliers can be fractional as well and when using <macro set> to manipulate them one needs to prepend leading zeroes to the fractional component of the value which used to be shown in the Stretch Blt modes discussion, now it just demonstrates use of fxpset.  This is a right pain and having recently come across another example that needs this in spades we now have the fxpset option.  Here one decides how many fixed decimal places one is going to use and passes that as N and multiplies the values in the expression by a corresponding amount (so for three decimal places you multiply by 1000).  So from my Corsi Block Tapping task where we have nine different targets on the screen and the coordinates of them have been generated randomly in counters 100 to 117 (a pair of them for each target, first being X and second being Y) with values between 0 and 100 where in order to display them they need to be 0.00 to 1.00 we have:

~1 <macro fxpset 2 .b1x. = c100> <macro fxpset 2 .b1y. = c101>
<macro fxpset 2 .b2x. = c102> <macro fxpset 2 .b2y. = c103>
<macro fxpset 2 .b3x. = c104> <macro fxpset 2 .b3y. = c105>
<macro fxpset 2 .b4x. = c106> <macro fxpset 2 .b4y. = c107>
<macro fxpset 2 .b5x. = c108> <macro fxpset 2 .b5y. = c109>
<macro fxpset 2 .b6x. = c110> <macro fxpset 2 .b6y. = c111>
<macro fxpset 2 .b7x. = c112> <macro fxpset 2 .b7y. = c113>
<macro fxpset 2 .b8x. = c114> <macro fxpset 2 .b8y. = c115>
<macro fxpset 2 .b9x. = c116> <macro fxpset 2 .b9y. = c117>;
0 <dfm ~.fm. STAT> <dwc 0,0,255 STAT> <xy ~.b1x., ~.b1y.> "■", <xy ~.b2x., ~.b2y.> "■", <xy ~.b3x., ~.b3y.> "■", <xy ~.b4x., ~.b4y.> "■",<xy ~.b5x., ~.b5y.> "■",<xy ~.b6x., ~.b6y.> "■",<xy ~.b7x., ~.b7y.> "■",<xy ~.b8x., ~.b8y.> "■", <wc 255,255,0> <xy ~.b9x., ~.b9y.> "■";

   Note that we are deliberately using two items, one to set the macros and one to use them as per the usual you can't define a macro and use that new value in the same item when using the legacy tilde macro expansion character, if the in place back tick macro expansion code had been written when I wrote the Corsi Block Tapping task then one item could have been used.




DMDX Index.