This article provides a Surfer script to blank a grid file above or below a given Z value.
To run this script:
- Copy the text below, or download the attached BAS file: BlankByLevel.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 14\Scripter.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- 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.
- 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 February 13, 2017