Programming Module
The Programming module is the main module where you do work in the Develop workspace. It lets you make, save, open, edit, compile, run, and debug AeroScript program files (.ascript). You can also make and compile AeroScript library files (.ascriptlib) that you can import into an AeroScript program. Other file types that you can edit in this module include text (.txt) and INI (.ini) files.
Programming Toolbar
Name | Type | Description |
---|---|---|
New File (Ctrl+N) |
Button |
Makes a new project file. The options are as follows: |
New Program File - Makes a new AeroScript program file with the extension .ascript. |
||
New Library File - Makes a new AeroScript library file with the extension .ascriptlib. |
||
New INI File - Makes a new INI file with the extension .ini. For information about how to use this file type in the Programming module, refer to the Working with INI Files section of this page. |
||
Open File (Ctrl+O) |
Button |
Opens an existing AeroScript program or library file, compiled versions of those files, text files, and INI files. You can open files directly from the Controller File System and the MDK File System. |
Save |
Button |
Saves your AeroScript program files, AeroScript library files, text files, and INI files. The options are as follows: |
Save (Ctrl+S) - Saves the changes that you make to an existing file. The file must be open in the Programming module and its tab must be selected. |
||
Save As (Ctrl+Shift+S) - Saves a new file to the Controller File System or the MDK File System. You can save it as an AeroScript library file (.ascriptlib), AeroScript programming file (.ascript), text file (.txt), or an INI file (.ini). |
||
Build (Ctrl+Shift+B) |
Button |
Compiles the AeroScript program or library file. You can do the build operation when a program is not loaded on a task or after the program is edited. To look at the build output, click the Build tab in the Programming drawer at the bottom of the module. |
Load |
Button |
Loads a program on the assigned task. If the program has not been compiled or has changed from the last time it was compiled, the program will compile before it is loaded. |
Run (F5) |
Button |
Runs an AeroScript program. The program must be open in the application and its tab must be selected. The Run feature operates in all of the ways that follow: |
If you already loaded the program, then the application runs the compiled program on the assigned controller task. The controller updates the task state as follows and shows it in the Task Errors section of the Programming drawer in the application:
|
||
If you compiled the program and it has not changed, then the application loads the program before the program starts running on the task. |
||
If you did not compile the program or did not change it from the last time it was compiled, then the application compiles and loads the program before the program starts running on the task. |
||
For more information about how to run a program on a task, refer to the Running a Program on a Task section of this page. |
||
Pause (F12) |
Button |
Pauses a program or library so you can do an inspection of the program variables. For more information, refer to the Inspecting Program Variables section of this page. |
Stop Task (Shift+F5) |
Button |
Stops the task that is assigned to the selected program. This program must be open in the application and its tab must be selected. If a different program is also running on that same task, the task will still stop. |
Stop All Tasks (Ctrl+Shift+F5) |
Button |
Stops all of the programs on all of the tasks. |
Step Over (F10) |
Button |
Executes one line of the program. If the program line is a function call, the debugger will execute the full function and move to the next program line. |
Step Into (F11) |
Button |
Executes one line of the program. If the program line is a function call, the first line of the function will execute. |
Step Out (Shift+F11) |
Button |
Executes the current function. Then moves to the next program line. |
For information about how to add or remove a breakpoint when you debug a program, refer to the Debugging Programs section of this page. |
||
Expand/Restore |
Button |
In the top-right part of the module header, click the Expand button to let the module fill all of the workspace area. While it is expanded, you can click the Restore button to let the module go back to its original size. |
Menu |
Button |
You can find more settings for the Programming module. To do this, select the Menu button. Then click Settings. In the Settings dialog, make sure the Programming section is selected. |
Running a Program on a Task
You can open more than one file, but you can run only one program at a time on a task. If it is necessary for you to run two or more programs at the same time, see Tasks Category for information about how to configure two or more tasks. You will also find information about how to add, remove, and edit tasks.
For more information about how to load and run a program, refer to the Programming Toolbar section of this page.
Assigning Programs to Tasks in the Assignments Drawer
The Assignments drawer shows each task that you configure. Expand the Assignments drawer by clicking the expander icon for << Assignments in the top-right corner of the Programming module. At the bottom of the drawer, you can add a task by selecting one that is available and clicking the Add Task button.
Click and drag the programs to assign them to a specific task on the controller. You can assign more than one program to the same task.
Editing Programs and Libraries
As you work in a file, AeroScript syntax highlighting is enabled and the autocomplete feature gives you options for different commands that you can use. If you write new functions as part of a library, the application adds them to the autocomplete feature so you can easily access them while you write code. You can also use the this feature to find items such as:
The editor will show syntax errors as you type. Click the Compiler Errors and Warnings tab in the Programming drawer at the bottom of the module to look at all of the compiler errors and warnings.
For information about how to add different types of comments to your AeroScript program, see Comments and Whitespace.
For a list of programs that will help you start doing work in the AeroScript programming language and the Programming module, see AeroScript Example Programs.
Debugging Programs
To add or remove a breakpoint from a program line, put your cursor on the line, open the Debug menu, and select Toggle Breakpoint. You can also click in the far left margin of the editor next to the program line to toggle a breakpoint.
For more information about how to add or remove a breakpoint and debug a program with the Step Over, Step Into, and Step Out buttons, refer to the Debug Menu section of the Editor Menus.
Debugging a Library Function Used by Multiple Programs
When you debug a library function that is used by multiple programs, the Task Context drop-down box lets you select which task and corresponding program the Run, Stop, Step Over, Step Into, and Step Out buttons will apply to. This drop-down box comes into view only when two or more AeroScript programs are using the same library and you use breakpoints to debug a library function. The Task Context arrow lets you select the task of one of the programs that is calling the library function. Thus, you can see the values of the arguments that are passed from that program to the library function.
For Example
In the figure that follows, Program1.ascript and Program2.ascript use the same library where a breakpoint was added to debug a library function. In the Task Context drop-down box, Task 1 is selected. This task corresponds to Program1.ascript and Task 2 corresponds to Program2.ascript. When you click the Run button, Program1.ascript will continue execution and Program2.ascript will stay paused. The Run, Stop, Step Over, Step Into, and Step Out buttons will apply only to Program1.ascript.
Editor Menus
These menus come into view while you do work in an AeroScript program or library file, an INI file, or a text file. They have the features that follow:
Shows you how to save, print, and access the code within your AeroScript programming file, AeroScript library file, an INI file, or a text file.
Name | Type | Description |
---|---|---|
File |
Menu |
New - Makes a new AeroScript program file with the extension .ascript. |
Open - Opens an existing AeroScript program or library file, compiled versions of those files, text files, and INI files. You can open files directly from the Controller File System and the MDK File System. |
||
Save - Saves the changes that you make to an existing file. The file must be open in the Programming module and its tab must be selected. |
||
Save As - Saves a new file to the Controller File System or the MDK File System. You can save it as an AeroScript library file (.ascriptlib), AeroScript programming file (.ascript), text file (.txt), or an INI file (.ini). |
||
Save All - Saves changes to all of the files that are open in the Programming module. |
||
Print - Prints the file that is open and selected in the Programming module. |
||
Print Preview - Shows you how the selected file will look as a printed document. |
||
Recent Files - Shows a list of the most recent files that you opened. |
Shows you how to quickly make changes to your code. You can also access part of this menu when you right-click in the file that you are doing work in.
Name | Type | Description |
---|---|---|
Edit |
Menu |
Undo - Deletes the last change that you made to a file. |
Redo - Lets you restore the last change that was deleted by the Undo action. |
||
Cut - Removes text from its current location and puts it on the virtual clipboard. The information is stored there until you overwrite it with the next Cut or Copy action. |
||
Copy - Makes a copy of the text in its current location and puts it on the virtual clipboard. The information is stored there until you overwrite it with the next Cut or Copy action. |
||
Paste - Inserts text into the part of a file that you specify. This is the most recent information that you put on the virtual clipboard by using the Cut or Copy action. |
||
Delete - Removes the selected text and code from a file. |
||
Select All - Selects and highlights all of the information in a file. |
||
Find - Lets you search for specified words or phrases within a file. Click the Find Options button to configure your search parameters, which include Match case, Match whole word, and Search pattern. These search parameters are defined as follows: |
||
Match case - Finds only the words or phrases that use the same capitalization as the word or phrase that you enter. |
||
Match whole word - Finds only the full words that are the same as the full word that you enter. Capitalization does not have an effect on this type of search. |
||
Search Pattern > Normal - Searches for text in the file that is the same as the search term that you enter. |
||
Search Pattern > Regular expression - Searches for text in the file that is the same as the regular expression that you enter. A regular expression is a search pattern that can match two or more words as an alternative to matching the exact search term. |
||
Search Pattern > Wildcard - Searches for text in the file that is the same as a search term that contains wildcard characters. These characters can match text where there are unknown characters or different word endings. |
||
Search Pattern > Shorthand - Searches for text in the file that contains the letters of the search term in order. Non-whitespace characters can be between the search pattern characters. This is almost the same as an acronym search, but it is not necessary for the letters that match to be capitalized or follow an underscore. |
||
Search Pattern > Acronym - Searches for words in a file that are the same as the acronym that you enter. The first letter of a word then each capital letter or each letter that follows an underscore (_) make an acronym for that word. |
||
Go to Definition - Lets you quickly navigate to where a user-defined function is implemented from where that function is called. The function can be in the same AeroScript program (.ascript) file. It can also be in a separate AeroScript library (.ascriptlib) file if the library source file is available. This feature helps you quickly find the function's implementation so it is not necessary to scroll through the file or use the search functionality. |
Shows you how to adjust the view for program lines and zoom levels.
Name | Type | Description |
---|---|---|
View |
Menu |
Show Line Numbers - Shows the number for each program line. If you turn off this feature, no program line numbers are shown. |
Highlight Current Line - Highlights the program line that you put the cursor on. If you turn off this feature, no program lines are highlighted. |
||
Zoom In - Increases the zoom level on the code that you are looking at. |
||
Zoom Out - Decreases the zoom level on the code that you are looking at. |
||
Reset Zoom - Resets the zoom level on the code that you are looking at. |
Shows you how to run and debug your code. For information about how to add or remove a breakpoint when you debug a program, refer to the Debugging Programs section of this page.
Name | Type | Description |
---|---|---|
Debug |
Menu |
Run - Runs an AeroScript program. The program must be open in the application and its tab must be selected. The Run feature operates in all of the ways that follow: |
If you already loaded the program, then the application runs the compiled program on the assigned controller task. The controller updates the task state as follows and shows it in the Task Errors section of the Programming drawer in the application:
|
||
If you compiled the program and it has not changed, then the application loads the program before the program starts running on the task. |
||
If you did not compile the program or did not change it from the last time it was compiled, then the application compiles and loads the program before the program starts running on the task. |
||
For more information about how to run a program on a task, refer to the Running a Program on a Task section of this page. |
||
Pause - Pauses a program or library so you can do an inspection of the program variables. For more information, refer to the Inspecting Program Variables section of this page. |
||
Stop - Stops the task that is assigned to the selected program. This program must be open in the application and its tab must be selected. If a different program is also running on that same task, the task will still stop. |
||
Stop All - Stops all of the programs on all of the tasks. |
||
Step Over - Executes one line of the program. If the program line is a function call, the debugger will execute the full function and move to the next program line. | ||
Step Into - Executes one line of the program. If the program line is a function call, the first line of the function will execute. |
||
Step Out - Executes the current function. Then moves to the next program line. |
||
Toggle Breakpoint - Adds or removes a breakpoint based on the conditions that follow. If the program line that you put the cursor on does not have a breakpoint, one is added. If the program line that you put the cursor on has an existing breakpoint, it is removed. |
||
Clear All Breakpoints - Removes all of the breakpoints from your AeroScript program or library file. |
||
Automatically Open Programs - This setting determines if the Programming module will automatically open programs that are running on the controller and which programs are opened. For a program to be automatically opened, it must be compiled with debug symbols and the source (.ascript) file must be available. The program will come into view in the Assignments drawer under the task it is running on. Programs will be automatically opened when you first navigate to the Programming module or if a program is started externally through one of the APIs. Programs will not be automatically opened if the Assignments drawer already shows them under a specified task or they are compiled without debug information. |
||
Automatically open all programs - All of the programs that are currently running will be automatically opened. This includes programs that you start manually in the Programming module, externally through one of the APIs, and through Program Automation. For information about Program Automation, see Program Automation Module. |
||
Don't automatically open the programs run by Program Automation - Only the running programs that you start manually in the Programming module or start externally through one of the APIs will be automatically opened. AeroScript programs that are running in Program Automation will not be automatically opened. |
||
Don't automatically open programs - None of the running programs will be automatically opened. |
Programming Drawer
You can find this drawer at the bottom of the Programming module. It has the features that follow:
Name | Type | Description |
---|---|---|
Build |
Tab |
Shows the build output. |
Compiler Errors and Warnings |
Tab |
Shows all of the compiler errors and warnings. This tab continuously examines the code for errors and warnings while you do work in an AeroScript program or library file. |
Task Errors |
Tab |
Shows all of the errors for a task. Also shows the current task state of a program. The task states are as follows:
|
Program Variables |
Tab |
Lets you do an inspection of program variables that are in scope while an AeroScript program or library is paused. Variables of the data type struct and array cannot be inspected. For more information about program variables, refer to the Inspecting Program Variables section of this page. |
Message Log |
Tab |
Shows all of the messages that are written by tasks and logged with the Message Log Functions. This tab does not filter messages based on the selected program. For more information about program messages, refer to the Viewing Program Messages section of this page. |
Expand |
Button |
Opens the Programming drawer so you can see all of its data. |
Collapse |
Button |
Closes the Programming drawer. |
Inspecting Program Variables
IMPORTANT: Variables of the data type struct and array cannot be inspected.
The Program Variables tab in the Programming Drawer supplies the information that follows about a variable:
- Name - The name of the variable as defined in the program.
- Value - The current value of the variable.
- Data Type - The AeroScript data type of the variable. See Fundamental Data Types for more information.
- Scope - The scope of the variable. See Variable Scope for more information.
You must pause a program or library before you can do an inspection of the program variables that are in scope. To pause a program or library, click the Pause button or set a breakpoint. For information about how to set a breakpoint, refer to the Debugging Programs section of this page.
Viewing Program Messages
By default, the Message Log tab in the Programming Drawer shows a maximum of 1000 messages before older messages are removed from view. To change the message limit and other Message Log settings, select the Menu button. Then click Settings. In the Settings dialog, select the Programming section. Then scroll to the bottom to see the Message Log settings.
IMPORTANT: The Message Limit setting applies only to the maximum number of messages that show in the Message Log tab. It does not have an effect on the file size of the MessageLog.log file. To prevent performance issues from occurring, Aerotech recommends that you use the MessageLogClear()
function to clear the MessageLog.log file at regular intervals.
For more information about the Message Log, see Message Log Overview.
Working with Compiled Programs and Libraries
You can open compiled AeroScript programs (.a1exe) the same as other files. Compiled programs cannot be modified. But you can assign them to tasks and run them as described in the Programming Toolbar section of this page.
Tip: To make sure that the application can identify the source program file (.ascript) with the compiled program file (.a1exe), turn on the Compile with debug information setting before you compile the program. To adjust this setting, select the Menu button. Then click Settings. In the Settings dialog, select the Programming section. Then scroll to the Building part of that section.
- In Studio, select the Develop tab.
- Open the AeroScript program that you want to compile.
- On the Programming toolbar, click the Build button. The application puts the compiled program in the same directory as the source file. The source file can be in the Controller File System or the MDK File System.
You can use library files to extend the AeroScript programming language by creating your own functions that you can call to. You can also build your file to make sure there are no errors. For more information about library files, see Libraries.
Tip: To make sure that the application can identify the source library file (.ascriptlib) with the compiled library file (.a1lib), turn on the Compile with debug information setting before you compile the library.To adjust this setting, select the Menu button. Then click Settings. In the Settings dialog, select the Programming section. Then scroll to the Building part of that section.
- In Studio, select the Develop tab.
- Open the AeroScript library that you want to compile.
- On the Programming toolbar, click the Build button. The application puts the compiled library in the same directory as the source file. The source file can be in the Controller File System or the MDK File System.
Tip: For more information about how to use compiled program and library files and how you can protect your intellectual property, see Program Automation Module.
Debugging Compiled Programs
You can debug compiled programs. But before you do that, you must identify the AeroScript program source file. To do this, load or run the compiled program on a task. If the automatic process cannot find the program source file, click the Find AeroScript Program… button to manually identify the file. This button comes into view when you open a compiled program in the Programming module. When the Programming module shows the source code in the compiled program, you can use the debug tools but you cannot edit the code. You can edit the code only in the source .ascript file. For information about how to debug a program, refer to the Debugging Programs section of this page.
IMPORTANT: If you compile a program with the Compile with debug information setting turned off, the application will not be able to identify the source program file (.ascript) with the compiled program file (.a1exe). You also cannot debug that program or use breakpoints. To adjust this setting, select the Menu button. Then click Settings. In the Settings dialog, select the Programming section. Then scroll to the Building part of that section.
Working with INI Files
You can use the Programming module to look at and edit INI (.ini) files. INI files contain values that correspond to a specific key. You can put these keys into sections for organization.
The INI file format is as follows:
- Key-value pairs are defined by a key, followed by an equal sign (
=
), followed by a value. You can put key-value pairs in a section or keep them separate. - Sections are defined by a section name in square brackets. All the key-value pairs that you put under a section name will be contained in that section.
- Comments are defined by a semicolon (
;
) or a number sign (#
). They are followed by the comment text. Comments must be on their own line.
Example INI File
; INI File Example
# This is a global key-value pair that is not contained within a section.
axis = 0
# The key-value pairs that follow are contained within the speeds section.
[speeds]
low_speed = 10
high_speed = 20
# The key-value pairs that follow are contained within the distances section.
[distances]
distance1 = 100
distance2 = 25
You can also use AeroScript to do the operations that follow:
- Read a value.
- Adjust or make a new value.
- Search to see if a section exists.
- Delete a section or key.
For information about how to use INI files with AeroScript, see File INI.
MachineApps Programming Module
When you add the Programming module to a MachineApp, you can create, save, open, edit, compile, run, and debug AeroScript program files. For information about how to do this, see MachineApps Programming Module.
Changing the Module Layout
You can change the size of the module when you click and drag the border with other modules in the workspace.
In the top-right part of the module header, click the Expand button to let the module fill all of the workspace area. While it is expanded, you can click the Restore button to let the module go back to its original size.