Follow

Can I write a Surfer script to grid and contour many data files with consecutive names?

Yes, you can write a script for looping through the process of gridding, contouring, and printing out separate data files that are saved with consecutive names (i.e. datafile1.dat, datafile2.dat, etc). A sample script demonstrating this is shown below.

To run this script:

  1. Copy the script below, or download the attached BAS file: Loop-ConsecutiveDataFileName.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.
     

*********

Sub Main
	
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

'This starts a loop to grid, contour, and print out 5 separate data files
'that have consecutive names such as datafile1.dat, datafile2.dat, etc.

	For i = 1 To 3

		'Opens a new plot document
  			Dim Plot As Object
  			Set Plot = SurferApp.Documents.Add

		'Specifies the path to the data file
  			Path = "c:\temp\SAMPLE"+Format(i)

		'Create a grid from teh data file
  			SurferApp.GridData(DataFile:=Path+".DAT", OutGrid:=Path+".grd")

 		'Creates a contour map from the grid file
  			Dim Map As Object
  			Set Map = Plot.Shapes.AddContourMap(GridFileName:=Path+".grd")

  		'Prints the plot document
			Plot.PrintOut

	Next i

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.