Application Message Functions

The Application Message API lets you show messages, get user input, and select files in Automation1 Studio, Automation1 MachineApps, or a custom .NET application. These AeroScript functions run on the Automation1-iSMC. But they are handled through a connected Automation1-MDK application, such as Automation1 Studio. Before you use these functions, you must connect Automation1 Studio or another application that registers for this callback to the controller.

Tip: By default, Automation1 Studio and Automation1 MachineApps try to register for Application Message and Application Frequency Response callbacks. The first application that registers will get the callbacks. The next application that tries to register will get an error. You can change the default behavior of Automation1 Studio in Settings. You can change the default behavior of a MachineApp in the MachineApps workspace in Automation1 Studio.

Message Notifications

Use the AppMessageDisplay() function to show a message. Each message shows a toast notification in the application toolbar. You can see all messages in the Notifications tab in the sidebar. Use the AppMessageDisplayDismiss() function to dismiss the messages from the sidebar. Before you use these functions, you can use their related App*IsRegistered() functions to see if they are registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

You can show information, warning, or error notifications. If you do not specify the $severity argument to the AppMessageDisplay() function, you will show an information notification.

User Input

Message Box

Use the AppMessageBox() function to show a message and custom buttons in a message box. You can specify the title, the message, the number of buttons, and the text for each button. The function returns the index of the button that you click. If you click the ‘X’ in the title bar to cancel the message box, the return value is -1. Before you use this function, you can use the AppMessageBoxIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

Use the $severity argument to show an information, warning, or error icon in the title bar of the message box. If the $takesFocus argument is 0, the message box shows in the Develop workspace. If the $takesFocus argument is 1, the message box shows in the active window.

Message Input

Use the AppMessageInputBox() function to show a message box that lets you enter an input value. You can specify the text for the title and the message that shows in the message box. You can also specify the default input value. When you click OK on the message box, the function returns the input value. When you click the ‘X’ in the title bar, the return value is always an empty string. Before you use this function, you can use the AppMessageInputBoxIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

Use the $severity argument to show an information, warning, or error icon in the title bar of the message box. If the $takesFocus argument is 0, the message box shows in the Develop workspace. If the $takesFocus argument is 1, the message box shows in the active window.

Message Menu

Use the AppMessageMenu() function to show a message box that lets you select from a list of items. You can specify the text for the title and the message that shows in the message box. You can also specify which item is selected by default. When you click OK on the message box, the function returns the index of the item you selected. When you click the ‘X’ in the title bar, the return value is always an empty string. Before you use this function, you can use the AppMessageMenuIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

Use the $severity argument to show an information, warning, or error icon in the title bar of the message box. If the $takesFocus argument is 0, the message box shows in the Develop workspace. If the $takesFocus argument is 1, the message box shows in the active window.

File Selection

File Open

Use the AppMessageFileOpen() function to show the Open File dialog. This dialog lets you select the name of a file on the controller file system. The return value is the name of the file that you select. When you click the ‘X’ in the title bar, the return value is always an empty string. Before you use this function, you can use the AppMessageFileOpenIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

You can specify the text for the dialog title. You can also specify a default directory and a default file. Use the ‘/’ separator to specify relative paths to a directory on the controller file system. Use the $filter argument to filter which file extensions show in the dialog. The filter string starts with the name of the filter followed by the ‘|’ separator and the filter pattern. You can also use the ‘|’ to separate multiple filter strings in the $filter argument. An example value for $filter argument is “Dat files|*.dat|Text files|*.txt”

If the $takesFocus argument is 0, the message box shows in the Develop workspace. If the $takesFocus argument is 1, the message box shows in the active window.

File Save

Use the AppMessageFileSave() function to show the Save File dialog. This dialog lets you select the name of a file on the controller file system. The return value is the name of the file that you select. When you click the ‘X’ in the title bar, the return value is always an empty string. Before you use this function, you can use the AppMessageFileSaveIsRegistered() function to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

You can specify the text for the dialog title. You can also specify a default directory and a default file. Use the ‘/’ separator to specify relative paths to a directory on the controller file system. Use the $filter argument to filter which file extensions show in the dialog. The filter string starts with the name of the filter followed by the ‘|’ separator and the filter pattern. You can also use ‘|’ to separate more than one filter strings in the $filter argument. An example value for $filter argument is “Dat files|*.dat|Text files|*.txt”.

If the $takesFocus argument is 0, the message box shows in the Develop workspace. If the $takesFocus argument is 1, the message box shows in the active window.

See the File and Directory Functions topic for more information about working with files.

Related Help Pages 

Develop Workspace