Libraries
This AeroScript program creates an AeroScript library and uses it in a program.
// Library Example (Libraries_LibraryImport.ascriptlib): // This example demonstrates how to create a simple library that can be built // and imported by other AeroScript programs. // See Libraries_LibraryImportTest.ascript for instructions on how to import this // library. // In this example, this library is exposing an enumeration // which is required to call into the library functions below. // If you do not want to expose an enumeration or structure, // you can omit the library keyword. library enum LaserState On Off end // Expose a function to set the state of the laser. library function SetLaser($laserState as LaserState) if ($laserState == LaserState.On) AnalogOutputSet(X, 0, 1.0) else AnalogOutputSet(X, 0, 0.0) end end // Expose a function to move the axis by a specific distance. library function MoveAxis($axis as axis, $distance as real) SetupAxisRampType($axis, RampType.Linear) SetupAxisRampValue($axis, RampMode.Rate, 100.0) MoveIncremental($axis, $distance, 50.0) WaitForMotionDone($axis) end
// Library Example (Libraries_LibraryImportTest.ascript): // This example demonstrates how to create a simple library that can be built // and imported by other AeroScript programs. // Instructions: // 1. Build Libraries_LibraryImport.ascriptlib to create Libraries_LibraryImport.a1lib. // 2. Build Libraries_LibraryImportTest.ascript and run the program. This program // will call into the Libraries_LibraryImport.a1lib library. // Import the library. import "Libraries_LibraryImport.a1lib" as static program // Enable and home the axis. Enable(X) Home(X) // Call into the library to enable the laser. SetLaser(LaserState.On) // Call into the library to perform a series of moves. MoveAxis(X, 50.0) MoveAxis(X, -50.0) // Call into the library to disable the laser. SetLaser(LaserState.Off) // Disable the axis Disable(X) end