Application Object Properties Script

This script demonstrates all the properties in the Application object. If you wish to run the script, open Scripter and then open ApplicationObjectProperties.bas from the Surfer Samples folder.


' ApplicationObjectProperties.bas demonstrates the properties

' of the Surfer Application Object.

' See ApplicationObjectMethods.bas for the methods of the

' Surfer Application Object.

' TB - 17 Oct 01.

' DO - 1 Dec 08, replaced "surf" with "SurferApp".


Sub Main

Debug.Print "----- ";Time;" -----"


'Get existing Surfer instance, or create a new one If none exists.

On Error Resume Next 'Turn off error reporting.

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

If Err.Number<>0 Then

Set SurferApp = CreateObject("Surfer.Application")


End If

On Error GoTo 0 'Turn on error reporting.


SurferApp.Visible = True

SurferApp.WindowState = srfWindowStateNormal

SurferApp.Width = 600

SurferApp.Height = 400



Debug.Print "-----------------------------------------------------"

Debug.Print "Surfer ";surf.Version;" Application Object Properties"

Debug.Print "-----------------------------------------------------"


Debug.Print "Application= ";SurferApp.Application


Debug.Print "ActiveDocument= ";SurferApp.ActiveDocument; '"Plot1.srf" (read-only)

'Set the active document to "Plot1". (Can omit ".srf").


'Set the active document to the first doc in the Documents Collection.



'ActiveWindow is "Plot1" or "Plot1:1" (read-only)

Debug.Print ". ActiveWindow= ";SurferApp.ActiveWindow

'Set the active window to the first window in the Windows Collection.



Debug.Print "BackupFiles= ";SurferApp.BackupFiles;

'Change to File | Options is saved when Surfer closes.

SurferApp.BackupFiles = True

Debug.Print ". New BackupFiles= ";SurferApp.BackupFiles


Debug.Print "Caption= ";SurferApp.Caption;

SurferApp.Caption = "Surfer "+SurferApp.Version

Debug.Print ". New Caption= ";SurferApp.Caption


Debug.Print "DefaultFilePath=";SurferApp.DefaultFilePath;

'New default path is used during current session of Surfer,

' but does not change default path in File | Options.

SurferApp.DefaultFilePath = "D:\INCOMING\"

Debug.Print ". New DefaultFilePath=";SurferApp.DefaultFilePath


Debug.Print "FullName = "; SurferApp.FullName

Debug.Print "Name = ";SurferApp.Name

Debug.Print "Path = ";SurferApp.Path


AppActivate "Surfer"

Debug.Print "Surfer Application Window Height = ";SurferApp.Height;

SurferApp.Height = SurferApp.Height + 10

Debug.Print ". New height = ";SurferApp.Height


Debug.Print "Surfer Application Window Width = "; SurferApp.Width;

SurferApp.Width = SurferApp.Width + 10 '0 = top of screen.

Debug.Print ". New width = ";SurferApp.Width


Debug.Print "Surfer Application Window Left = ";SurferApp.Left;

SurferApp.Left = SurferApp.Left + 10 '0 = far left edge of screen.

Debug.Print ". New left = ";SurferApp.Left


Debug.Print "Surfer Application Window Top = ";SurferApp.Top;

SurferApp.Top = SurferApp.Top + 10

Debug.Print ". New Top = ";SurferApp.Top

'AppActivate "ApplicationObjectProperties"

Debug.Print "Page Units ="; SurferApp.PageUnits;". PageUnits Name = ";

If SurferApp.PageUnits = 1 Then Debug.Print "srfUnitsInch"

If SurferApp.PageUnits = 2 Then Debug.Print "srfUnitsCentimeter"


'The application is the topmost level object, so it is it's own parent.

Debug.Print "Surfer Application Parent = ";SurferApp.Parent


Debug.Print "ScreenUpdating = ";SurferApp.ScreenUpdating;

SurferApp.ScreenUpdating = True

Debug.Print ". New ScreenUpdating = ";SurferApp.ScreenUpdating


Debug.Print "ShowStatusBar = ";SurferApp.ShowStatusBar;

SurferApp.ShowStatusBar = True

Debug.Print ". New ShowStatusBar = ";SurferApp.ShowStatusBar


Debug.Print "ShowToolbars =";SurferApp.ShowToolbars;

Debug.Print ", sum of srfTBMain =";srfTBMain;

Debug.Print " + srfTBDraw =";srfTBDraw;

Debug.Print " + srfTBMap =";srfTBMap

SurferApp.ShowToolbars = srfTBMain+srfTBDraw+srfTBMap 'Turn them all on.


Debug.Print "Application Visible = ";SurferApp.Visible;

SurferApp.Visible = True

Debug.Print ". Now Application Visible = ";SurferApp.Visible


Debug.Print "There are";SurferApp.Windows.Count;" windows in the Windows Collection."


Debug.Print "WindowState =";SurferApp.WindowState

Debug.Print " srfWindowStateMaximized =";srfWindowStateMaximized

Debug.Print " srfWindowStateMinimized =";srfWindowStateMinimized

Debug.Print " srfWindowStateNormal =";srfWindowStateNormal

Debug.Print 'a blank line


End Sub