Follow

How can I tell Surfer Scripter what to do when my script encounters an error?

This article contains a sample script for setting error handling in Scripter.

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 14\Scripter.
  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 February 14, 2017

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.