Application Object

The Application object represents the Surfer program. All navigation through the Surfer object model begins with the Application object. The Application object is a single instance of Surfer and it is the root of all objects in Surfer. External programs will typically create an instance of the Application object during initialization. In Visual Basic (VB) this is done using the function as in:

Set SurferApp = CreateObject("Surfer.Application")

The CreateObject function activates a new instance of Surfer, and returns a reference to the Application object to your script. If Surfer is already running, and you do not want to start a new instance of Surfer, use the VB GetObject function instead of CreateObject:

Dim SurferApp As Object

Set SurferApp = GetObject(,"Surfer.Application")

The GetObject function obtains the Application object from the currently running instance of Surfer. If Surfer is not already running, the function will fail. Call the Application object’s Quit method to close Surfer from a script.

When Surfer is started by a script, its main window is initially hidden. To make the Surfer window visible, you must set the Application object’s Visible property to True:

Set SurferApp = GetObject(,"Surfer.Application")

SurferApp.Visible = True

Most of the gridding-related operations are methods of the Application object. Use the GridData, GridFunction, GridMath, GridFilter, GridSplineSmooth, GridAssignNoData, GridConvert, GridVolume, GridSlice, GridTransform, GridExtract, and GridCalculus methods to create new grids and perform computations with grids.

Other methods and properties of the Application object let you move and resize the Surfer window, adjust the main window state (maximized, minimized, hidden), change the window caption, and modify preference settings.

The Application object provides two important collections that allow access to the next level of objects in the hierarchy. Use the Documents property to obtain a reference to the Documents collection object, and use the Windows property to obtain a reference to the Windows collection object. The Documents and Windows collection objects provide access to the other objects in the object hierarchy. You can access the currently active document and window objects with the Application object’s ActiveDocument and ActiveWindow properties.

Set the ScreenUpdating property to False to disable screen updating and make your scripts execute more quickly. Turning off screen updating can greatly increase the performance of Automation when you want to perform a number of actions that cause screen redraws.

The following table provides the properties of the application object:

Property

Description

ActiveDocument

Returns the active document object. It is a read-only property.

ActiveWindow

Returns the active window object. It is a read-only property.

Application

Returns the application object. It is a read-only property.

BackupFiles

Returns/sets the global file backup state.

Caption

Returns/sets the main window title.

DefaultFilePath

Gets/Sets the default path for opening files.

Documents

Returns the Documents collection. It is a read-only property.

FullName

Returns the Full path and name of the application. It is a read-only property.

Height

Returns/sets the height of the window.

Left

Returns/sets the coordinate for the left edge of the window.

Name*

Returns the name of the application (no path). It is a read-only property.

PageUnits

Returns/sets the global page unit type.

Parent

Returns this object. It is a read-only property.

Path

Returns the path of the application (no filename). It is a read-only property.

ScreenUpdating

Returns/sets the redraw flag for all view windows.

ShowStatusBar

Returns the status bar visibility state.

ShowToolbars

Returns/sets the visibility state of all the toolbars.

Top

Returns/sets the coordinate for the top edge of the window.

Version

Returns the application version.

Visible

Returns/sets the application window visibility.

Width

Returns/sets the width of the window.

Windows

Returns the Windows collection.

WindowState

Returns/sets the state of the main application window.

The following table provides the methods of the application object:

Methods

Description

CrossValidate2

Performs cross validation.

GridAssignNoData

Assigns the NoData value to grid nodes inside or outside specified boundaries.

GridCalculus2

Performs various calculus operations on an existing grid.

GridConvert2

Converts between various grid formats.

GridData6

Creates a grid from irregularly spaced XYZ data.

GridExtract2

Extracts a subset from an existing grid file.

GridFilter2

Applies a filter to an existing grid.

GridFunction2

Creates a new grid from the specified function.

GridMath3

Grid-to-grid and grid-to-constant math operations when more than two grids are combined or when assigning Z values to NoData nodes.

GridMosaic3

Creates a new grid by mosaicing one or more input grids.

GridProject

Converts the coordinate system of a grid file from one system to another and saves the results to a new grid file.

GridResiduals2

Compute the difference between XYZ data and a grid surface.

GridSlice

Compute cross section data through a grid surface.

GridSplineSmooth2

Smooths an existing grid using cubic splines.

GridTransform2

Scales, Offsets, Mirrors, or Rotates an existing grid file.

GridVolume2

Computes the volume under or over a grid surface.

NewGrid

Creates a new grid object.

NewGridMathInput

Sets the grid names and parameters to use with the GridMath2 command.

NewVarioComponent

Creates a variogram component object.

PointSample

Computes the interpolated Z value on a gridded surface at given XY locations saved in a data file.

Quit

Terminates the application.

*default property

Example 1

This script displays all the properties in the Application object.

Example 2

This script displays all the methods in the Application object.

Example 3

The following script demonstrates how the Application object is used.

Sub Main

 

'Declare SurferApp as an object

Dim SurferApp As Object

 

'Creates an instance of the Surfer Application object and assigns

'it to the variable named "SurferApp"

Set SurferApp = CreateObject("Surfer.Application")

 

'Makes Surfer visible

SurferApp.Visible = True

 

End Sub