Optional Arguments and Named Arguments

Many procedures, especially the methods provided by Surfer Automation objects, accept a large number of arguments. Some of the arguments are required. Every required argument must be supplied or the script will fail to run. Some arguments are optional. Optional arguments may be omitted and the procedure will assume a default value for the missing arguments.

For example, the PlotDocument object’s "PrintOut" method accepts up to seven arguments, all of which are optional:

 

plot.PrintOut(Method, SelectionOnly, NumCopies, Collate, _

xOverlap, yOverlap, Scale )

Since the arguments are optional, you can skip all or some of them when calling the procedure. To print three copies at fifty-percent scale, for example, you would supply just the NumCopies, and Scale argument values. These arguments must be listed in the correct position, separated by commas, as shown below:

 

Set SurferApp = CreateObject("Surfer.Application")

Set plot = SurferApp.Documents.Add

plot.PrintOut , , 3, , , , 50

Although only two of the seven argument values are supplied in this example, the appropriate number of commas must be used to mark the positions of the missing arguments. Since inserting the right number of commas can be troublesome, you can supply the arguments by name rather than by position. Named arguments are specified by the argument name followed by a colon and an equal sign (":="), followed by the argument value:

Set SurferApp = CreateObject("Surfer.Application")

Set plot = SurferApp.Documents.Add

plot.PrintOut Scale := 50, NumCopies := 3

Named arguments may be listed in any order without regard to the order they appear in the procedure's definition.

See Also

Surfer Object Model

Overview of Surfer Objects

Using Surfer Objects

Derived Objects

Using Collection Objects

PlotWindow, WksWindow, and GridWindow Objects

Object Hierarchy

Object List

Parent and Application Properties

Subroutines and Functions