Block basics

A block is identified by a given name and can take any number of user-defined attributes, which act as variables within the block code.

The basic syntax of <block> is very straightforward.

Here is the example above written as a <block> statement:

<block name="block_test" col="store" value="1">
  <sel value="{@col}={@value}"/>
</block>

The general idea for the above statement is to wrap the original selection statement in opening and closing <block> tags. Once a <block> has been created, it must be given a name so it can be referenced in the future by other pieces of Macro Language code. name is the only required attribute for a <block> statement. All other attributes are simply user-defined variables that can be inserted into statements within a block. These variables are defined in the following way:

<block name="[BLOCK_NAME]" [VAR_1]="" [VAR_2]="">

In the above line of code, the new block is given a name and two variables are defined (but have not been assigned a value).

Now that the variables are defined, they're inserted into a regular Macro Language expression as scalar values via the following syntax:

{@var1}

This syntax takes user-defined variables from an opening <block> tag and inserts them into Macro Language expressions. This process, which results in our original expression, is called expanding the block. You can see exactly how your <block> code will expand by selecting Code > Expand in place in Macro Language Workshop.

The following is the block example above in Macro Language Workshop:

Click Code > Expand in place. Macro Language Workshop expands the <block> and inserts parameterized values into the statement, as shown below: