Application Button Functions

Application button functions let you update the active state of customizable buttons that are part of the Buttons & Indicators module. These AeroScript functions run on the Automation1-iSMC. But they are handled through a connected Automation1-MDK application known as Automation1 MachineApps. Before you use these functions, you must connect an Automation1 MachineApps application that registers for this callback to the controller. If a MachineApp uses the Buttons & Indicators module with a button or indicator that you can control with AeroScript, it automatically registers for the necessary callbacks. To see if a MachineApp is registered to handle those callbacks, use the example program that follows.

Program Example

// Returns true if a MachineApp is registered to handle
// the callbacks used by the Buttons & Indicators module.
// You can use this to see if a MachineApp with a button
// or an indicator that you can control through AeroScript is open.
var $isRegisteredByAMachineApp as integer
$isRegisteredByAMachineApp = AppButtonSetStateIsRegistered() ||
AppIndicatorOnIsRegistered() || AppIndicatorOffIsRegistered()

Set a Button State

Use the AppButtonSetState() function to set all buttons with the specified ID or name to the specified state. Before you use this function, you can use the AppButtonSetStateIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

function AppButtonSetState($buttonId as integer, $stateId as integer)

Sets the specified button to the specified state. This function must have a connected Automation1 Studio, Automation1 MachineApps, or a custom .NET application that registers to handle it. If there is not an application connected to your controller that can handle this function, an error will occur. If you need to do a check, call the AppButtonSetStateIsRegistered() function.

Arguments

$buttonId  The ID of the button on which to set the state.

$stateId  The ID of the state to set on that button.

function AppButtonSetState($buttonName as string, $stateName as string)

Sets the specified button to the specified state. This function must have a connected Automation1 Studio, Automation1 MachineApps, or a custom .NET application that registers to handle it. If there is not an application connected to your controller that can handle this function, an error will occur. If you need to do a check, call the AppButtonSetStateIsRegistered() function.

Arguments

$buttonName  The name of the button on which to set the state.

$stateName  The name of the state to set on that button.

function AppButtonSetStateIsRegistered() as integer

Returns if the AppButtonSetState() function is registered by an application.

Returns

If the function is registered by an application, returns 1. Otherwise, returns 0.

Program Example

// Set a button to its default state
AppButtonSetState("Button1", "Default State")
// Use a variable to iterate over state IDs
var $stateIterator as integer = 0
// Set a button to each of its three states in order
for $stateIterator = 0 to $stateIterator < 3
	AppButtonSetState(1, $stateIterator)
	$stateIterator++ 
end