Since the macros that are created for us along with the new macros that will be created are saved in an XML file, it is a good idea to take a look at the XML format of a macro. 4D macros are built using customized XML tags called "elements". Each start tag of an element must have an ending tag. A start tag is represented by <tag>, an ending tag looks like </tag>, however <tag/> is both a start and end tag.
The basic requirement of a macro is defined in the sample macro below:
<macro name="">
<text>
</text>
</macro>
An example macro using the basis requirements:
<macro name="Macro_ForLoop">
<text> For($i;1;Records in selection(<Caret/>))
End for
</text>
</macro>
Here are the descriptions of the 4D Macro tags.
<macros> </macros>
Initializes and ends a macro file. This tag is required in a macro file.
<macro> </macro>
Defines a single macro and its attributes.
<selection/>
This tag is replaced by the selected text when the macro is inserted. If no text is
selected, then the tag is empty.
<text> </text>
This tag will encapsulate what you want the macro to place in your method.
The contents can be either comments, or 4D commands.
<caret/>
After the macro has been inserted, the cursor returns to this position.
<user_4D/>
The current 4D user is returned in this position
<user_os/>
The current system user name is returned in this position.
<method_name/>
The current method name is returned in this position
<time/>
The current time is returned in this position.
<clipboard/>
The contents of the clipboard is returned in this position