Chapter 2. Getting Started

Table of Contents

2.1. The Script Log
2.2. Accessing Scripts
2.2.1. Starting a New Script
2.2.2. Adding a Script to the List
2.2.3. Editing a Script
2.2.4. Running a Script Manually
2.2.5. Running a Script at Startup
2.2.6. Modifying the List
2.3. The Script Editor

Whenever the DataHub is running, Gamma, its scripting engine, is running. Gamma is an interpreter. Think of it as a program that is always running in the background, that you can interact with at any time. The only time Gamma stops is when the DataHub shuts down. You can write and run scripts for Gamma, or interact with it using the Script Log.

2.1. The Script Log

The Script Log displays output from Gamma scripts, and can also be used to conduct interactive sessions, like a terminal. To open the Script Log, right click on the DataHub icon in the system tray, and select View Script Log. The Script Log should appear on your desktop:

You can use the text entry field at the bottom to send code to Gamma. Try the following:

  1. Type: a = 5; and press Enter
    You should see the following on the screen:
    --> a = 5;
    5
    You have just created a symbol (a) and assigned it a value (5). That symbol acts as a variable, and is now available to Gamma until the DataHub shuts down. Notice that the Script Log inserts a prompt (-->) and shows your command to help you identify what you typed in.
  2. Press the Clear button to clear the Script Log. Press the Close button to close the Script Log window, then reopen it.
  3. Type: a; and press Enter
    You should see the following on the screen:
    --> a;
    5
    Sure enough, the value of a is still in Gamma
  4. Type: princ("Hello world.\n"); and view the results:
    --> princ("Hello world.\n");
    Hello world.
    t
    Why the t? It is the return value from the princ function, a logically true value. Every Gamma function returns a value. The string 'Hello world.' is the byproduct or result of running the function, but the actual return value is t. For more details on Gamma programming, please refer to the Gamma manual.
  5. Now, let's see a value in the DataHub. Start DataSim, then type: $DataSim:DataSim.Sine; and press Enter. You should see something like this:
    --> $DataSim:DataSim.Sine;
    -0.47552825816976968
    This was the value of the DataSim.Sine point in the DataSim domain of the DataHub at the moment you pressed the Enter key.
    [Note]

    The colon character (:) is used to divide the domain name from the point name. The dollar sign character ($) tells Gamma that the colon is part of the variable name, not a sytactic element.

  6. You can re-enter up to the last 10 commands by pressing the down arrow on your keyboard. Try it now. Press the down arrow until you see the last command, $DataSim:DataSim.Sine;, and press Enter. Try it several times. You will get different values because the DataSim program is running.

This gives you a taste of working with Gamma, but to accomplish anything really useful and to save your work, you'll need a script. The following sections will explain how to access and edit scripts, and create your own.