Macro Execution Reference

AdvantageBuilder provides simple, consistent functions for executing macros across all scripting engines. This section explains how to call macros synchronously or asynchronously, how to pass parameters, and how return values work.

Overview

Macros can be executed in two modes:

callMacro (synchronous)

Executes a macro and waits for it to finish. Returns the macro output as a string.

JavaScript / JScript.NET


var params = { Name: "User", Count: 5 };
var result = callMacro(false, "MyMacro", "Common\\Utilities", params);
writeln(result);
    

PowerShell


$params = @{ Name = "User"; Count = 5 }
$result = callMacro $false "MyMacro" "Common\Utilities" $params
Write-Host $result
    

Parameters

Notes

callMacroAsync (asynchronous)

Executes a macro in the background without waiting for completion. Does not return a result.

JavaScript / JScript.NET


var params = {};
callMacroAsync(false, "LongRunningTask", "Common\\Tasks", params);
    

PowerShell


$params = @{}
callMacroAsync $false "LongRunningTask" "Common\Tasks" $params
    

Notes

Parameter Passing

Parameters may be any object supported by the scripting engine. AdvantageBuilder does not impose restrictions on the types you can pass.

Example


    var params = {
    FirstName: "John",
    LastName: "Smith",
    Items: [1, 2, 3],
    Details: { Active: true, Level: 4 }
    };

    callMacro(false, "ProcessUser", "Common\\Users", params);
    

Parameters can be simple or deeply structured. Both synchronous and asynchronous macro execution support full object passing.

Return Values

Synchronous macros return a string. The content depends on what the macro writes using:

Asynchronous macros do not return a value.

Choosing an Execution Mode

Scenario Recommended Function
Need macro result callMacro
Long-running background task callMacroAsync
UI must remain responsive callMacroAsync
Macro triggers other macros callMacro