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:

  • Idle - A task is enabled, but does not have an AeroScript program loaded or running on it. The task is also not running a command queue.
  • ProgramReady - The program is loaded on the assigned controller task and is ready to run. Click the Run button to start program execution.
  • ProgramRunning - The program is currently executing on the assigned controller task.
  • ProgramPaused - The program was running but is paused at this time because you manually paused it or the program executed a breakpoint. It is still loaded on the assigned controller task. To continue program execution from where it was paused, click the Run button. The program will continue to run until you pause it again or the program executes another breakpoint. For more information, refer to the Debugging Programs section of this page.
  • ProgramComplete - The program completed execution but it is still loaded on the assigned controller task. If you click the Run button, the program starts executing from the beginning.

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:

Programming Drawer

You can find this drawer at the bottom of the Programming module. It has the features that follow:

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.

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: 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

Copy
; 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.