4.2. Hello World

This simple example demonstrates how to edit a new script by editing the .constructor method.

Edit the Constructor

  1. Create a new script whose main class is called 'HelloWorld'. Here's how.
  2. The body of a typical script is written as part of the .constructor method. Find the following lines to start editing:
    /* Write the 'main line' of the program here. */
    method HelloWorld.constructor ()
    {
    }
  3. In between the brackets of the .constructor method, enter the following:
    pri
    Notice that a drop-down box appears:
    This box will appear any time you begin to write a function or variable name that is already available in Gamma.
  4. Continue writing:
    princ(
    The box now shows you the princ function syntax, in this case a symbolic expression (s_exp), commonly know as a symbol. Please refer to the Gamma manual for more information about function syntax and arguments.
  5. Continue editing the princ function until your .constructor function looks like this:
    /* Write the 'main line' of the program here. */
    method HelloWorld.constructor ()
    {
        princ("Hello world.\n");
    }

Run the Script

Click the blue arrow icon in the Script Editor toolbar to run the script, and then check the results in the Script Log window:

If you don't get a 'Hello world' string in the Script Log, see Appendix A, Basic Troubleshooting.

Evaluate a Selection

Here's a way to evaluate just a part of your code:

  1. In the Script Editor, use the cursor to select just the text:
    princ("Hello world.\n");
  2. From the Script menu, select Evaluate Selection.
    You should see the string 'Hello world.' appear in the Script Log.

This feature of the Script Editor lets you run any part of a script without running the whole thing.