Macro Input/Output
Macro Input
The Macro Input tool serves as a connection point for your macro, enabling it to accept input from other tools. Each Macro Input tool that you place in a macro creates an input connection point for that macro when it is used in a project.
![image-20240327-143943.png](../__attachments/3905290519/image-20240327-143943.png?inst-v=c3007bf4-8f91-43d3-9633-90859273c945)
Each Macro Input tool is a logical connection point for your macro. When the macro is run in a project, the project's connection to the macro supplies the macro with a data stream. During development and testing of the macro, you can specify the expected schema of the input data in one of three ways:
A sample file, which must be in DLD format. If you enable automatic field mapping, the sample file can be used as a template for mapping input data to macro processes. Your sample file should ideally be:
Small enough to work with in a reasonable time frame.
Representative of the size and variety of data you anticipate as the macro's input.
Limited to fields actually used by the macro.
Visible to anyone editing the macro.
Data in CSV format which represents a schema for mapping input data to macro processes.
Synthesized data from a schema that you define.
Macro Input tool configuration parameters
The Macro Input tool has two sets of configuration parameters in addition to the standard execution options:
Configuration
Input label | If specified, tag for the input file. This is optional and defaults to Input. If you have more than one Macro Input tool in a project, each tool must have a unique tag. |
Automatic field mapping | If selected, uses the available schema definition to map input data to macro processes. Missing fields are filled with default values. |
New fields to N connector | If Automatic field mapping is selected, optionally sends fields encountered at run time that are not part of the schema definition to the N connector. |
Required | If selected, makes input mandatory. |
Limit records | If selected, limits the number of records read. |
Only the first | If Limit records is selected, specifies the number of records to be processed. |
Sample data
Sample from | Specifies the source of sample data: either a DLD File, a CSV Sample, or Synthesized data based on a user-defined schema. |
Input file | If Sample from is DLD File, the file specifying a schema for mapping input data to macro processes. |
Input data | If Sample from is CSV Sample, the data describing a schema for mapping input data to macro processes. |
Schema | If Sample from is Synthesized, the schema for mapping input data to macro processes. |
Configure the Macro Input tool
Select the Macro Input tool, and then go to the Configuration tab on the Properties pane.
Enter a tag for the output file in the Input label box.
If your macro will have only one input, Input label should be Input. If your macro will have multiple inputs, each tool must have a unique tag. When the macro is used in a project, the first letters of Input label tags are used to label the macro's connectors. It's a good idea to assign descriptive tags with unique first letters.
Optionally, select Automatic field mapping to use the available schema definition to map input data to macro processes.
If you selected Automatic field mapping, you may optionally select New fields to N Connector to route unmapped or new fields around macro processing.
Optionally, select Required to make the input mandatory.
If you don't want to process the entire file, select the Limit records box on the Configuration tab and specify the desired number of records in the Only the first box.
Optionally, select the Sample data tab, and then select Sample from and select the source for a sample file or data:
If you choose DLD File, specify a sample file, which must be in DLD format. If you enabled Automatic field mapping, the sample file will be used as a template for mapping input data to macro processes. The file should be small and contain only fields that will be used by the macro.
If you choose CSV Sample, enter a sample of the expected input data in CSV format. describing a schema for mapping input data to macro processes.
If you choose Synthesized, enter the schema for mapping input data to macro processes as Name and Type pairs.
Optionally, go to the Execution tab, and then set Web service options.
If you use Automatic field mapping, you can connect the N connector between the Macro Input and Macro Output tools to route unmapped or new fields around macro processing. The N connection combines the "N" fields and the processed fields together, attempting to keep the original input order. If the macro creates any new fields, these are appended to the end of the record. Select Automatic field mapping on the Macro Output tool to "undo" any input mapping and restore original field names.
Macro Output
The Macro Output tool serves as a connection point for your macro, enabling it to send its results downstream to the project in which it is embedded. Each Macro Output tool can output its data stream to multiple downstream destinations. However, during development and testing, the Macro Output tool sends results to a Data Viewer tab so that you can inspect the output without actually writing files.
Macro Output tool configuration parameters
The Macro Output tool has a single set of configuration parameters in addition to the standard execution options:
Output label | If specified, tag for the output file. This is optional and defaults to Output. If you have more than one Macro Output tool in a project, each tool must have a unique tag. |
Automatic field mapping | If selected, "undoes" input mapping and restores fields to their original names and order. |
Configure the Macro Output tool
Select the Macro Output tool, and then go to the Configuration tab.
Enter a tag for the input in the Output label box.
If your macro will have only one output, Output label should be Output. If your macro will have multiple outputs, each tool must have a unique tag. When the macro is used in a project, the first letters of Output label tags are used to label the macro's connectors. It's a good idea to assign descriptive tags with unique first letters.
Optionally, select Automatic field mapping.
If you use Automatic field mapping on the Macro Input tool, you can connect the N connector between the Macro Input and Macro Output tools to route unmapped or new fields around macro processing. The N connection combines the "N" fields and the processed fields together, attempting to keep the original input order. If the macro creates any new fields, these are appended to the end of the record. Selecting Automatic field mapping on the Macro Output tool "undoes" any input mapping and restores the original field names.
Optionally, go to the Execution tab, and then set Web service options.