Script editor

Functionality

The script editor allows you to create, view, edit and test scripts. With a script, you can build your own GIS and Remote Sensing application.

To open the script editor:

The script editor automatically opens when you create a new script. The script editor is also opened when you edit an existing script, e.g. by double-clicking a script in the Catalog. For other methods to open the script editor, see How to edit objects.

Parts of the script editor:

The script editor has a menu bar, a description bar, a toolbar, a script tab, a parameters tab, a default values tab and a context-sensitive menu.

The description bar and the toolbar can be moved and docked along an edge of the window. You can also make them floating. You can hide or show the description bar, the toolbar and the status bar via commands on the View menu. These settings as well as the size of the window etc. are stored per script in the registry. The script that is closed last thus determines the appearance of any newly opened script.

 

To run a script:

If a script contains parameters, the Run Script dialog box will appear. This dialog box lists:

Script tab

On the script tab you have to type your script expressions. Lines in a script may contain commands for object management (e.g. copy or delete), for the display of data objects (open or show), and for the creation and calculation of data objects. All MapCalc, and TabCalc formulas, and all ILWIS expressions to perform operations may be used. You can also call other scripts or other Windows applications from within a script. For more information on valid expressions, refer to Appendices : ILWIS commands, Appendices : ILWIS expressions or Appendices : ILWIS script language (syntax).
An example of a script to create slope maps in percentages and in degrees is presented in Map & Table calculation : creating and running scripts and in How to use parameters in scripts.

Using parameters on the Script tab:

You can directly type map and column names in expressions, but you can also use parameters. Parameters in a script replace (parts of) object names, operations, etc. Parameters in scripts work as DOS replaceable parameters in DOS batch files, and must be written on the Script Tab in the script editor as %1, %2, %3, up to %9. For more information, see below and/or How to use parameters in scripts.

Parameters tab

If you use parameters in your script, you are advised to specify names for the parameters on this Parameters tab. Parameter names will later on appear in the Run Script dialog box when a user runs the script. The user can then select object names for input parameters and/or type object names for output parameters. When your script does not have any parameters you can skip this tab.

Parameters tab options:

Nr of parameters: Select the number of parameters. Make sure that the number corresponds with the number of parameters defined in the script itself. The maximum number of parameters that can be specified is 9.
Name: Type a name for every parameter. It is advised to use names that clearly describe the meaning of each parameter. The parameter names will appear on the Default Values tab and in the Run Script dialog box.
Type: Select a type for each parameter; parameter types are used when you run the script. You can choose between:
Raster Map | Segment Map | Polygon Map | Point Map | Table | Column | Map List | Map View | CoordSystem | GeoReference | Domain | Representation | Filter | Script | Function | Matrix | Sample Set | 2-Dimensional Table | Annotation Text | String | Value | Filename
Include extension: Select this check box if the extension of an ILWIS object should be sent to the ILWIS command line when the script is executed.
Clear this check box if the extension of an ILWIS object should not be sent to the ILWIS command line when the script is executed. You can use this option when you wish to use suffixes behind object names etc.

When for a parameter type, you specify a regular ILWIS object (e.g. Raster map, Segment map, Table), it means that the parameter expects an ILWIS input object of a certain type (a raster map, a segment map, a table, etc.). In fact, in the Run Script dialog box which appears when the script is run, the user should select an ILWIS object of the specified type and thus supply the script with the necessary information to execute itself.

Special parameter types available on the Parameters tab:

Default Values tab

On the Default Values tab, you may fill out all variables / parameters as you would like to use them in the script. This tab is very useful when you want to test your script or when you directly want to run your script. The information on this tab is based on the information as specified on the Parameters tab. When your script does not have any parameters you can skip this tab.

Using the script editor

To cut, copy, paste and delete selections within the script editor:

You can cut, copy, paste and delete texts in the same way as in a text editor.

To reverse the last action:

To search for and/or replace certain characters or text:

You can search and replace texts in the same way as in a text editor.

To save a script:

When you close the editor and the script contains any unsaved changes, you will be prompted to save the script.

To save a script with a different name and/or location:

The Save As dialog box appears in which you can specify a name and a location to save the script.

To run or test a script from within the script editor:

 

  1. If your script does not contain parameters, the script will immediately be executed. 
  2. If your script does contain parameters with names specified on the Parameters tab, first the Run Script dialog box will appear. In the Run Script dialog box, all parameter names are listed as specified on the Parameters tab.
  3. If you did not specify default objects on the Default Values tab you will need to select objects for input parameters and/or type object names for output parameters.
  4. If you did fill out objects on the Default Values tab, the Run Script dialog box will already be filled out with these defaults.
  5. When the OK button is clicked in the Run Script dialog box and when all parameters are correctly specified, the script will be executed.

For more information about running scripts, e.g. to run a script from the command line, see How to run scripts.

To print a script or a selection of a script:

The Print dialog box appears in which you can select your printing options, such as the name of the printer you want to use and the number of copies you want.

To select the whole script:

You can now copy the script contents to the clipboard and paste it for instance in a document.

To open the script properties:

The Script Properties sheet will appear.

To open another script:

The Open dialog box appears in which you can select the script that you want to open.

To exit the script editor:

If the script contains any unsaved changes, you will be prompted to save the script.

Creating your own Help for a script

You can create your own Help for a script so that you can explain the meaning of parameters to other users of the script. For more information, see the Run Script dialog box.

See also: