Creating Scripts in Oasis Mon Taj
Creating Scripts in Oasis Mon Taj
Creating Scripts
in Oasis montaj
version 6.3
www.geosoft.com
Contents
Introduction 1
What is a Script? 1
Recording a Script 2
Viewing a Script 4
Script Commands 4
File Names 5
Editing a Script 7
Replacement Variables 8
Advanced Features 9
Quiet Mode 9
Running Variables From Multiple Scripts 9
Introduction
This technical note is intended to provide you with a basic introduction to Geosoft
Scripts in Oasis montaj. The paper describes what a script is, how you can use
them, and a tutorial will guide you through the process of creating, editing and
running your own script. A summary of script commands and replacement variables
(match strings) is provided for advanced users.
What is a Script?
If you perform a task repeatedly in Oasis montaj, you can automate the task using a
script. Geosoft Scripts are ASCII files that contain a series of actions or commands
that that you group together in a single file to accomplish a task automatically.
2. Select the script.omn file and then click the [Open] button to load the menu.
Recording a Script
You can record most Geosoft eXecutables (GXs) with a script. You cannot record
actions from GXs that require interactive input; for example, you cannot record
commands from a Wizard or interactive tool such as the Image Colour Tool.
1. To start recording a script, click the Start Script Recording button ( ) on the
main toolbar.
2. Specify a file name for the script (test.gs) and click [Save].
Note: From this point on, all of you actions in the program are recorded until you
click the End Script Recording button ( ).
In the following steps you will open a new database, import data, create a grid, create
a new map, display a grid on the new map, and add base map information to the map.
The tasks demonstrate some of the actions you can record with a script. The result of
this procedure will be a script containing these tasks.
1. On the Data menu, click New Database. The Create new database dialog box is
displayed. Specify a name for the database (Script_data.gdb) and click [OK] to
accept the default database size and compression mode.
2. On the Data menu, click Import and then click Geosoft XYZ. Click the [Browse]
button to find the XYZ data file named mag.xyz. This file is one of the sample
data files provided with Oasis montaj and should be located in your C:\Program
Files\Geosoft\Oasis montaj\data\various\ directory. Click [Open] to open the file.
3. Click the [Template] button. Accept the default settings and click [OK].
8. Click the [OK] button to accept the default settings and create the grid.
9. To create a new map, on the Mapping menu, click New Map, and then click New
map from X,Y.
10. Accept the default data range and click the [Next>] button.
11. Specify the map name as script_map and click the [Finish] button. A new blank
map is displayed on screen.
12. To display the grid on the map, on the Grid menu, click Display Grid and then
Single Grid. The Display grid on a map dialog box is displayed.
13. Click the [Browse] button and select the mag_script.grd grid.
14. Click [OK] to accept all default settings and draw the grid on the current map.
15. To draw a base map on the map, on the Mapping menu, click Base Map and then
Draw base map. Click the [Next] button twice and then the [Finish] button to
accept the default settings and plot the base map.
1. To stop recording the script, click the End Script Recording ( ) button.
There are two methods of running a Geosoft Script. You can run a script from Oasis
montaj or from the DOS prompt.
1. To run a Geosoft Script in Oasis montaj, click the Run Script ( ) button.
2. Select the script you would like to run (test.gs) and click the [Open] button.
3. The script executes the commands you recorded.
oms is the script program, test.gs is the Geosoft Script file to run
The OMS program is independent from Oasis montaj and does not affect its
execution. However, you will only be able to run GXs you are licensed for based
on your Oasis montaj license.
2. Press [Enter] and the script will execute the commands you recorded.
Viewing a Script
Geosoft Scripts are saved as ASCII files with a .gs extension. If you want to view a script,
you can do so by opening the script file in a text viewer such as Notepad. To view a script in
Oasis montaj, on the Edit menu, click Edit ASCII file. Use the [Browse] button to locate the
file you want to open (for example, test.gs).
The different parameters of a Geosoft Script file are illustrated in the example below. This
example shows part of test.gs script you recorded in the previous section. The entire file is
provided in the Sample Geosoft Script file on page 9.
/-------------------------------------------------------------------------
Header lines /LOG OPENED : Tue May 25 10:11:50 2004 SETINI
These lines are comments /------------------------------------------------------------------------- These lines set parameters
and begin with the / SETINI CREATE.CURDB="" for the CREATE GX that is
character. The header SETINI CREATE.BLOBS="-1" used to create a database.
includes the date and time SETINI CREATE.USERS="-1" Each parameter is
the script was created. SETINI CREATE.ERASE="-1" formatted in a similar way.
SETINI CREATE.PAGESIZE="1024" For example:
SETINI CREATE.SUPER="" CREATE.LINES=200
SETINI CREATE.PASSWORD=""
CREATE refers to the GX
SETINI CREATE.COMPRESSION="1"
name, .LINES is a
SETINI CREATE.NAME="Script Data"
property of the database
SETINI CREATE.LINES="200"
(# of database lines), and
SETINI CREATE.CHANNELS="50"
=200 indicates the
SETINI CREATE.COMPRESSION="1"
actual number of lines
SETINI CREATE.PAGESIZE="1024"
created in the new
GX CREATE GX geogxnet.dll(Geosoft.GX.NewGDB.NewGDB;Run)
database.
This line indicates the CURRENT Database,"d:\uxodemo\Script Data.GDB"
GX that is associated SETINI IMPORT.FILE="C:\\Program Files\\Geosoft\\Oasis montaj\\data\\various\\mag.xyz"
with the SETINI SETINI IMPORT.TEMPLATE=".\\default.i0"
parameters above this SETINI IMPORT.MODE="Replace"
line. The GX here is the GX import.gx
CREATE GX. CURRENT Database,"d:\uxodemo\Script Data.GDB" CURRENT
SETINI BIGRID.CHAN="mag" This line opens or selects a
SETINI BIGRID.GRID=".\\mag_script.grd(GRD)" specified object (map or
database). In this example, DB
is a database object and
script_data.gdb is the database
name.
Script Commands
Geosoft Script commands enable the script to perform different functions with specified
parameters. The sample script text (above) shows how these commands are formatted in the
file. The parts of a single line in a script are:
SETINI IMPORT.MODE="Replace"
Command Script Parameter Value
The script parameters for GXs (that support scripts) are found in the GX help topics in the
Online Help System. The related script parameter for each option in the dialog box is shown
in italic text in the GX help file. The help text for the import mode parameter shown above
is:
Import mode "Append", "Replace" or "Merge". "Append" mode causes imported lines to be renamed
as a new version if a line already exists in the database. "Replace" mode causes
existing line/channels to be replaced by the imported data. "Merge" mode causes
existing channels to be merged with imported channels. Merging may involve re-
sampling of the data to the smallest common fiducial increment.
File Names
File names identified in scripts may use a prefix <label> to identify a directory in which to
locate a file. Allowable <label> values are:
The following table summarizes the script commands you can use.
Command Parameters Description
OFF Default
Editing a Script
You can edit the commands, parameters or values in a Geosoft Script file by editing the text.
Using the sample script file (test.gs) you created earlier, the procedure below shows you how
to change the map name so a different map is created when you run the script.
1. Open the test.gs script file by clicking on the Edit menu, and then click Edit ASCII file.
2. Scroll down until you see the following line:
SETINI NEWMAP.MAP=".\\script_map.map"
5. In the text editor (notepad) click File and then Save to save the modified script.
6. Run the script. The script will run through the process you recorded and create the map
as script2_map.map instead of script_map.map.
Replacement Variables
A replacement variable is a named storage object containing data that can be modified. Each
variable is identified by a unique name. Replacement variables enable scripts to be more
flexible by making easier for the user to modify values from the command line instead of
editing the script each time it is run.
This example will show you how you can use replacement variables to specify different
settings each time you run the same script file. The script below (var.gs) draws the line path
with a specific line colour and thickness on a map.
CURRENT DB,{{MyDatabase}}
CURRENT MAP,{{MyMap}}
SETINI PATH.LINE_COLOR="{{LineColor}}"
SETINI PATH.LINE_THICKNESS="{{LineThickness}}"
SETINI PATH.TICKFLAG="0"
SETINI PATH.LABEL_FORMAT="TL"
SETINI PATH.LABEL_LOCATION="1"
SETINI PATH.LABEL_SIZE="0.1"
SETINI PATH.LABEL_COLOR="R0"
SETINI PATH.LABEL_WEIGHT="0"
SETINI PATH.H_OFFSET="2.0"
SETINI PATH.V_OFFSET="0.0"
SETINI PATH.GAP="0.0"
GX path.gx
Each replacement variable in the script has a specific name surrounded by two pair of braces
{{VariableName}}. This script contains four replacement variables:
{{MyDatabase}}
{{MyMap}}
{{ LineColor }}
{{ LineThickness }}
The variable name must contain ONLY letters, numbers, and underscores. No spaces are
allowed in the variable name.
The first variable {{MyDatabase}} holds the value for the name of the database that the
script will use when it runs. This enables you to specify a new database name from the
command line when you run a script. The second variable {{MyMap}} holds the value for
the name of the map. The last two variables hold the line colour {{ LineColor }} and line
thickness {{ LineThickness }} values for the PATH GX.
To run this script and specify values for the replacement variables, you would type the
following text at the DOS command prompt:
oms var.gs MyDatabase=script_data.gdb MyMap=script_map.map LineColor=r
LineThickness=0.18
This command will run the script (var.gs) and specify the project as script.gws, the database
as script_data.gdb, the map name as script_map.map, the line path colour as red, and the
line path thickness as 0.18.
If the value for a replacement variable contains a space or any characters other than a
number, letter, decimal or underscore, you must specify the value in quotation marks. For
example, LineColour=light red.
Advanced Features
The following features are suggested for advanced users who want to modify the way their
scripts are executed.
Q UIET M ODE
When a script is executed, the oms program displays progress information on screen. If you
want, you can suppress this feature, and improve the performance of your computer,
reducing the time it takes to process large files. To enable quiet mode, type /Q after the
project name in the command line:
oms test.gs script.gws /Q MyDatabase=script_data.gdb
Periods in replacement variable names are interpreted as a parameter from the parameter
block. For example, to get the line thickness from a script named Main.gs the variable would
be:
{{ Main.LineThickness }}
This is an advanced feature that is used to run variables from another script and is
recommended only for advanced users who are very familiar with using multiple scripts.
SETINI MAP.REFSPACE=""
SETINI MAP.REFTHICK="150"
SETINI MAP.REFCOLOR="k"
SETINI MAP.YORIENT="-1"
SETINI MAP.COMPASS="-1"
SETINI MAP.LLGRID="-5"
SETINI MAP.LLINCLONG=""
SETINI MAP.LLINCLAT=""
SETINI MAP.LLTHICK="150"
SETINI MAP.LLCOLOR="k"
SETINI MAPTITLE.TA1="Tutorial for working with Scripts"
SETINI MAPTITLE.TB1="Scripts in Oasis montaj"
SETINI MAPTITLE.TB2=""
SETINI MAPTITLE.TB3=""
SETINI MAPTITLE.TC1=""
SETINI MAPTITLE.TC2=""
SETINI MAPTITLE.TC3=""
SETINI MAPTITLE.TC4=""
SETINI MAPTITLE.TD1=""
SETINI MAP.TA1="Tutorial for working with Scripts"
SETINI MAP.TB1="Scripts in Oasis montaj"
SETINI MAP.TB2=""
SETINI MAP.TB3=""
SETINI MAP.TC1=""
SETINI MAP.TC2=""
SETINI MAP.TC3=""
SETINI MAP.TC4=""
SETINI MAP.TD1=""
SETINI MAP.MARGIN_BOTTOM="4"
SETINI MAP.MARGIN_RIGHT="1"
SETINI MAP.MARGIN_TOP="1"
SETINI MAP.MARGIN_LEFT="1"
SETINI MAP.REFCOLOR="k"
SETINI MAP.LLCOLOR="k"
SETINI MAP.TITLE=""
SETINI MAP.SUB_1=""
SETINI MAP.SUB_2=""
SETINI MAP.TA1="Tutorial for working with Scripts"
SETINI MAP.TB1="Scripts in Oasis montaj"
SETINI MAP.TB2=""
SETINI MAP.TB3=""
SETINI MAP.TC1=""
SETINI MAP.TC2=""
SETINI MAP.TC3=""
SETINI MAP.TC4=""
SETINI MAP.TD1=""
SETINI MAP.RPL0=""
SETINI MAP.RPL1=""
SETINI MAP.RPL2=""
SETINI MAP.RPL3=""
SETINI MAP.RPL4=""
SETINI MAP.RPL5=""
SETINI MAP.RPL6=""
SETINI MAP.RPL7=""
SETINI MAP.RPL8=""
SETINI MAP.RPL9=""
GX basemap2.gx
/-------------------------------------------------------------------------
/ LOG CLOSED : Mon Oct 04 13:46:53 2004
/-------------------------------------------------------------------------