Error handing in Surfer automation

Common or occasionally expected errors can prevent a script from running to completion.  Error handling commands enable a script to execute entirely regardless of error.

To run this script:

  1. Copy the script below, or download the attached BAS file: OnError.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.
     

*********

'OnError.bas shows an example of how to set error handling in Scripter
'==================================

Sub Main
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True
	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add
    On Error GoTo X
	SurferApp.GridData (DataFile:="c:\temp\ElevationData.xls", xCol:=2, yCol:=3, zCol:=3, OutGrid:="C:\temp\test.grd")
	X:  Err.Clear
	Dim MapFrame As Object
	Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:="C:\temp\ElevationGrid.grd")
Plot.SaveAs(FileName:="C:\temp\Elevation.srf")
End Sub

 

Updated November 2021

Was this article helpful?
1 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.