Using Surfer Objects

To access Surfer commands from your script you must create a Surfer Application object. To create an Application object, call the CreateObject function with Surfer.Application as the argument. The Application object is the root of an object hierarchy. Access all other Surfer Automation objects though the properties and methods of the Application object.

Every object has properties and methods associated with it. Properties are values describing the state of an object. Methods are actions an object can perform. Access properties and methods by typing the name of an object variable, followed by a period, followed by the property or method name.

You can use object properties as you would use variables: assign values to properties, branch based on the value of a property, or use the value of a property in calculations. You call an object’s methods as you would call subroutines and functions. Use the return values from methods the same as you would use return values from functions.

When you "drill through" the object hierarchy, you can store references to intermediate objects in variables, or you can string together long sequences of object references. For example, you can set the default font for a plot document in a single line:

' Assume "SurferApp" is a variable holding a reference to the Application object

SurferApp.Documents.Item(1).DefaultFont.Bold = True

Alternatively, you can store each intermediate object in variables as you traverse the object hierarchy:

' Assume "SurferApp" is a variable holding a reference to the Application object

Set docs = SurferApp.Documents

Set plot = docs.Item(1)

Set font = plot.DefaultFont

font.Bold = True

The second form - storing intermediate objects - is more efficient if you are performing several actions with the same object. A third alternative is to use the WITH…END WITH statement:

' Assume "SurferApp" is a variable holding a reference to the Application object

With SurferApp.Documents.Item(1).DefaultFont

.Bold = True

.Size = 12

.Color = SurferAppColorBananaYellow

End With

See Also

Surfer Object Model

Overview of Surfer Objects

Introduction to the Major Surfer Objects

Derived Objects

Using Collection Objects

PlotWindow, WksWindow, and GridWindow Objects

Object Hierarchy

Object List

Parent and Application Properties

Optional Arguments and Named Arguments

Subroutines and Functions