A Brief Tutorial on JavaScript in PRIMER
Brief Tutorial on JavaScript in PRIMER
While most people associate JavaScript with web pages and html it is a full-featured programming language. Additionally JavaScript is not Java! JavaScript is completely unrelated to Java.
Hopefully, enough people are familiar enough with JavaScript through the internet to be able to use it in PRIMER . JavaScript has all of the functionality you would expect from a programming language, such as:
- variables (strings, numbers, booleans, objects, arrays)
- functions
- control flow statements such as if , while , do , for , switch etc.
- objects
- arrays
- regular expressions
- maths functions (sin cos, log, sqrt etc)
Additionally, PRIMER extends JavaScript by defining several new object classes specifically for PRIMER . A detailed reference on these classes is given in the JavaScript API Reference Manual. Over time this functionality will be extended. If you need to do something which is not possible with the current functionality then contact Oasys Ltd Support.
Probably the best way to see what sort of things are easily possible in PRIMER using JavaScript is to look at the example scripts which are given out with PRIMER in the $OASYS/primer_library/examples directory. However, additionally a few example scripts are given here and documented. For more details on the classes described in these examples see the JavaScript API Reference Manual.