Script File Format

Script files are used by:

  • Execute Script option (under the Block > Manipulation submenu)

    The script file for this option is created through the Edit Script option (under the Block > Manipulation submenu).
  • Perform Addition option (under the Block > Transfer submenu)

    The script file for this option can either be created through the Addition Parameters option (under the Block > Transfer submenu) or through using the Edit Script option (under the Block > Manipulation submenu).

    Scripts for use in block modelling should not contain the Xcentre, Ycentre or Zcentre variables. These variables store coordinates as relative to the block's origin rather than real world coordinates. The reason for this is that using relative coordinates allow rotating, plunging and dipping of block models. To use the real world coordinates of these variables in a block model script, follow the steps below:

    • Block model is 0,0,0 and not dipping

      Create a new variable in the model, for example zmiddle (float). Then use the Calculate option (under the Block > Manipulation submenu) and enter " zmiddle " as the new variable and for the calculation enter " = zcentre ". This writes the real world Z to the new variable. You can then use zmiddle in your script instead of zcentre .
    • Block model is rotated, plunging or dipping

      As above but a more complex calculation is required to transfer zcentre to zmiddle . The easiest way to do this is to actually dump the block model as an ASCII text file and check the Dump as real world check box. Then copy and paste the zcentre column in the text file to the end of the file and re-import the block model with the new zcentre variable.

  • Flag Script option (under the Geology > Sampling submenu)

    The script files for these options are created through a text editor. The Notepad application is the default text editor for Windows, however, you can use the ENVIS_EDIT environment variable to reference a different text editor.
  • Isis (Database Utility).

    The script files for Isis are created through a text editor.
  • Execute Script option (under the File > Client Data submenu)
    The script file for this option is created through a text editor. The script allows customised importing of data.

Script files are ASCII files containing lists of conditions and expressions. The operators/functions that can be used in these conditions/expressions are listed in Appendix B of the Vulcan Core documentation.

  • Format
  • Commands
  • Where Are Scripts Used?

Format

The format of a script file is:

* <comments>
if (<condition>) then
    <statements>
elseif (<condition>) then
        <statements>
else
        <statements>
endif
<field> = <expression>

The script must finish with a carriage return. Scripts are not case sensitive, i.e. you can use either upper or lower case or a combination.

The if/elseif/else/endif statements can be nested in itself, for example

if (<condition>) then
    if (<condition>) then
            <statements>
    else
            <statements>
    endif
else
    <statements>
endif

Commands

In addition to conditions and expressions, there are several commands that can be used in the script files. These commands allow values to be printed while a script is being executed. This is useful for exporting databases and block models, user-customised reporting, and testing the script files.

The commands are:

PRINT (prints out a string to the screen)
FILEPRINT (prints out a string to a file)
OPEN (opens a file for output)

Sections for intialisation and exit can also be included in the script file. The sections allow commands to be executed before and after a script is used. The commands are described first, followed by the sections.

PRINT

The PRINT command has the following format:

PRINT("<format string>",<variable>,<variable>,.....) 

where <format string> defines how the variables are printed, <variable> ... is a comma separated list of script variables.

  MAPTEK_variable="MAPTEK"
print ("Company name is %10s.\n",MAPTEK_variable) > 

outputs:

Company name is MAPTEK

FILEPRINT

The FILEPRINT command has the following format:

FILEPRINT("<output file name>","<format string>",<variable>,<variable>,....

where <output file name> is the file to send the output to, <format string> defines how the variables are printed, <variable> ... is a comma separated list of script variables.

The name of the output file can be a set string, for example " hello.txt " or a variable containing the name of the file, for example variable HELLO has a character value of " hello.txt ". When the file name is " screen " then the output is sent to the computer screen instead of a file (that is FILEPRINT becomes PRINT ). If the file has not already been opened, then it is opened automatically with a status of " append " (see OPEN command).

For a character string to be printed you insert:

%s or %<width>s

where <width> is the width of the output filed in characters (optional).

For a numeric integer value to be printed, you insert:

%d or %<width>d

where <width> is the width of the output field in characters.

For a numeric real value to be printed, you insert:

%f or %<width>.<decimals>f

where <width> is the width of the output file in characters (combined option with decimals) and <decimals> is the number of decimals to print (only relevant if the width is specified).

There are three other control formats:

n (perform a carriage return and line feed) \
t (perform a tab) \
r (perform a carriage return only)

Example script

region ="IV"
tonnes = 123000 
fileprint("where.txt","The %s region has %12.3f tonnes in it.\n",region, tonnes) 

outputs to file " where.txt ":

The IV region has 123000.000 tonnes in it

Example script

printf("water\n\tfalling\n\t\tdown\rslowly\n")

outputs

water
falling
slowly down

OPEN

The OPEN command has the following format:

OPEN("<output file name>","<open status>" ) 

where <output file name> is the name of the file to open and <open status> is the status for opening the file.

The name of the output file can be a set string, for example " hello.txt " or a variable containing the name of the file, for example variable HELLO has a character value of " hello.txt ". If the file name is " screen ", then the output is sent to the screen instead of a file.

The <open status> must have one of two values: " new " or " append ".

When the status is " new ", the specified file will be created from scratch. If the file already exists, then it will be deleted first and then created. When the status is " append ", the file will be opened so that any new output is placed at the end of the file. If the file did not already exist, it will be created.

Example script

begin_init
collars = "collars.txt"
open(collars,"new")
surveys = "surveys.txt"
open (surveys,"new")
open("assays.txt","new")
end_init

This example script file opens three files: collars.txt , surveys.txt and assays.txt . It is a simple way of breaking a drillhole database into three relational tables.

We recommend that you enclose the Open statements inside a first-run check otherwise the files would be reopened every time the script is executed (see Initialisation and Exit ).

INITIALISATION/EXIT

The Initialisation section allows commands to be executed before a script is used. The Exit section allows commands to be executed after a script is used. This may be useful for performing cumulative reporting, opening files for exporting blocks, reporting success/failure for the complete execution of a script.

For format for the Initialisation section is:

begin_init 
<commands> 
end_init 

For format for the Exit section is:

begin_exit 
<commands> 
end_exit 

Example script

* Initialise a counter of the tonnes in a block model 
* This is executed only once before any blocks are examined. 
* 
begin_init 
total_tonnes = 0.0 
end_init 
* 
* This is the normal section performed on every block. 
* 
total_tonnes = total_tonnes + tonnes 
* 
* Report the total number of tonnes 
* This is executed only once after all the blocks have been processed. 
* 
begin_exit 
print("Total tonnes are %10d\n",total_tonnes) 
end_exit 

The above script adds up and reports all the tonnes in a block model.