4.8. Scripting Tips

Here are some ways to facilitate scripting.

4.8.1. Copying a complete tutorial

The code from DataHub tutorials can be copied directly from the text into the Script Editor. Here's how to make a new script from a complete tutorial.

  1. Open the DataHub Properties window and select the Scripting option.
  2. Click the New button. This dialog will appear:
  3. In the New class: field, enter a name of your choice.
  4. Click the OK button to create the file. The Script Editor will open, displaying a script template.
  5. Using the cursor or Ctrl-A, select all the text and delete it.
  6. Copy a complete tutorial from the DataHub Windows Help manual or online documentation into the Script Editor.
  7. Save and run the script using the blue arrow icon .

4.8.2. Setting up a scripting environment

If you are working on one script regularly and need to restart the DataHub often, here's a way to automatically open the Properties window, the Script Log and the Script Editor with your file loaded.

  1. Open the Properties window and Script Log.
  2. Position them on the screen, then close them. They will come up in the same place the next time you open them. (The Script Editor does not yet have this feature.)
  3. Write a script of these three lines:
        datahub_command ("(show_properties 1)");
        datahub_command ("(show_script_log 1)");
        edit_file ("c:\\projects\\myfile.g");
    Two slash marks (\\) are necessary—the first slash mark escapes the second one.
  4. Add this script to the list of scripts in the DataHub, and check the activation box beside it. Then next time you start the DataHub, the properties and script log windows will come up where they were before, and an editor will be opened on the file c:\projects\myfile.g.
  5. When you don't want the script to auto-load, just un-check the activation box.