[Feedback][Day 1][Day 2][Welcome Page]

shoeline2[1].gif (1488 bytes)

Running the Built-in Examples

JAS3 has a number of built-in example programs that show how to use the AIDA interfaces from both Java compiled code and from the Pnuts scripting language. To run the examples start JAS3, and from the welcome page click on examples. (If the welcome page is not automatically displayed use the icon to display it).

Currently the examples page contains Java and Pnuts examples (more types of examples will be added later).

Running the Pnuts examples is very straightforward, just click on the file to open it, then use the File, Run menu item to run the script (or use the Run item in the editor's popup menu, or just use the F2 key).

Each time you run a script a new Pnuts interpreter a console window is created. Once the script has completed you can type additional commands into the console to interrogate or operate on the objects created by the script. (You can also create a new interpreter console without first running a script by using the File, New, Pnuts Console menu item.). Try running several of the scripts and look at the code to see if you can understand what they do. Most of the examples are taken from the AIDA User's Guide which has more detailed description of each of the examples. The Pnuts Language Guide is also useful for understanding the syntax of the Pnuts examples.

Running the Java examples is very similar to running the Pnuts scripts. As before you click on the file to open it in the editor, but in the case of Java you have to compile the code before you can run it. To do this use the File, Compile menu item, followed by the File, Run menu item.

One thing worth mentioning is that both the Java and Pnuts examples are pure AIDA. This means that they do not depend in anyway on JAS3, you can use the exact same code outside of JAS3 provided you have set up your AIDA environment correctly.

Why do we support both scripting and Java when the examples look very similar and have basically the same functionality? The compiled Java code is more efficient that the equivalent script, it runs perhaps 10x faster. But the scripts are more suitable for experimenting with the AIDA objects, since you can type commands and see the results immediately. Fortunately any Java object can be easily manipulated from the scripting language, so we expect people to use some combination of the two, with the stable, time-critical components implemented in Java and the experimental parts in Pnuts. In the future we hope to support automatic translation from Pnuts -> Java to make the transition from Pnuts to Java easier.