Follow

How do I blank a Surfer grid file above or below a given Z value with Scripter?

This article provides a Surfer script to blank a grid file above or below a given Z value.

 

To run this script:

  1. Copy the text below, or download the attached BAS file: BlankByLevel.bas.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 15\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.
     

*********

 

'BlankAll.BAS blanks all grid files in a specified directory with a specific BLN file.
'You must specify the file directory and BLN file below.
'If the script appears to do nothing, make sure file_directory is valid.


Sub Main
Debug.Clear

''''''''''''' User Variables ''''''''''''''''''
'You must enter the path to the grid files and the name of the BLN file

file_directory	= "C:\temp\GRIDS\"

BLN_file = file_directory+"DemoRect.bln"

'''''''''''''''''''''''''''''''''''''''''''''''

	file_extension	= "grd"

	Set surf = CreateObject("surfer.application")
	surf.Visible = True 'Progress for each file can be seen in the status bar of the application.

	'Make sure the file extension has no extra . and the data directory has a trailing \
	file_extension	= LCase(Right(file_extension,(Len(file_extension) - InStrRev(file_extension,"."))))
	If  Len(file_directory)-InStrRev(file_directory,"\") <> 0 Then file_directory = file_directory + "\"

	grid_file = Dir( file_directory  + "*." + file_extension)

	On Error GoTo FileError
	While grid_file <> ""
		'Define output grid file directory & name
		blanked_file	= file_directory + Left(grid_file, Len(grid_file)-(Len(grid_file)-InStrRev(grid_file,".")+1) ) + "_blanked.grd"

		'Grid the data file with the current Surfer defaults (but do not fill the screen with grid reports)
		surf.GridBlank(file_directory + grid_file, BLN_file, blanked_file)

		Debug.Print grid_file
		grid_file = Dir() 'get next file

	Wend

	surf.Quit
	Exit Sub

	'Print a meaningful error message for each file that did not grid correctly
	FileError:
	Debug.Print  "Error:	" + blanked_file + "						" + Err.Description
	Resume Next
End Sub

 

Updated October 10, 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.