A Macro file (.txt typically) is a text file which has instructions and code which may be called from your Interface code. They may be passed parameters or request parameters when opening.
The macro file can be used to create controls, interfaces or simply process data and optionally passed data to use when ran.
An example is Image Button Red-Red.txt. This can be run from the File-->Run Macro from Folder menu option. When ran it will show information and request parameters while providing default values:
The box will also be shown if opened from code with no parameters: !runMacro Image Button Red-Red.txt
Or, it can be passed required parameters such as: !runMacro ImageButton Red-Red.txt,myButton, 40,40,20,5,Click Me!
Opening the file with NotePad shows the following:
The following tags are used in macro: <description> Provides the user information about the macro for the dialog box. <parameters> Provides the user a parameter list it requires for operation. <default> Default values for all parameters.
When called, the passed parameters are parsed into [arg0] to [arg99] to be used in the code.
While data cannot be directly returned by the macro file, it can set variables or control properties that can be read by the code that follows.
Example Macro Code for a macro saved as macAdd.txt: // Adds 2 parameters and returns as variable varMacResult
<description>Adds 2 values, stores results in varMacResult
<parameters>Value1, value2
<default>10,20
!makeVar varMacResult={ [arg0] + [arg1] }
Calling the macro and getting the result: !runMacro macAdd.txt,50,60 ? [varMacResult]
While there is no automated feature for creating a macro file, the easiest method if interface elements are needed is to:
•Start a new interface
•Create the elements desired
•Save the interface
•Open the interface file in a text editor
•Modify to add macro tags
•Modify code to use the passed arguments
•Save as a macro text file and test
Note: The macro dialog halts queue processing until completed.
|