Structure of a Script
A Mathscript Script is simply a sequence of Mathscript Statements. The statements should be placed on separate lines for legibility. In any case, each command statement, program statement, function statement, or LISP protocol should be terminated by a ; (semicolon).
There are 4 types of scripts: Gadget Scripts , Page Scripts , WorkBook Scripts , and File Scripts . All but File Scripts must be "attached" to their objects after compilation . File Scripts should be saved to disk after compilation. When a file script, say MyFile, is saved to disk, two files are created: MyFile.msp and MyFile.lsp. The compiled form (MyFile.lsp) is what is used if MyFile is loaded into a WorkBook. But if modifications are to be made, MyFile.msp is the one you edit. The .MSP file is the MathScript version, and the .LSP file is the LISP version.
When a File script is "loaded", a gadget script is activated, or a WorkBook or page entered, these scripts are executed, not compiled. This means that the compiled code (which already exists) is submitted directly to LISP.
Formally, the only Mathwright32 objects that may have scripts are the Gadgets: PushButtons, CheckBoxes, Sliders, Graph2D windows and Textlines. Using Graph2D windows, for example, you may create "User-Draw" Pushbuttons with arbitrary bitmaps and designs as wallpaper, and these may respond to the buttonclick by changing wallpaper if you wish. For more ambitious authors, you may create palettes by detecting where in the window the button was clicked (using getpoint) before processing.
Debugging
It is possible to "debug" Mathscript scripts in Listeners by executing them line-by line using the Execute option. Also in LISP mode, names can be evaluated by highlighting them, and pressing the right-mouse button.
Comments are available within scripts.
The commented text should be enclosed in apostrophes (e.g. ' This is a comment ' ). It may extend several lines, and begin or end either on a new line or within a line. As many comments as you like are admissible.