﻿'GetFilePath.bas shows how to open a dialog box to select a grid or
'data file to use, or to save an SRF file.

'========================================

Sub Main
	
	Dim SurferApp As Object
	Set SurferApp = CreateObject("Surfer.Application")
	SurferApp.Visible = True

	Dim Plot As Object
	Set Plot = SurferApp.Documents.Add

'GetFilePath format is in the form of:
'default file name, extension(s), default file path, dialog title, and option value.
'See Help | BASIC Language Help, UserInput | GetFilePath for option values

'Choose a grid file for contour map
	gridfilepath = GetFilePath( , "grd",SurferApp.Path+"\samples\","Open Grid File",0)

	Dim MapFrame As Object
	Set MapFrame = Plot.Shapes.AddContourMap(GridFileName:=gridfilepath)

'Choose a data file for post map
	datafilepath = GetFilePath("demogrid.dat","dat;txt;csv;xlsx;xls",CurDir(),"Open Data File",0)

	Dim MapFrame2 As Object
	Set MapFrame2 = Plot.Shapes.AddPostMap(DataFileName:=datafilepath)

'Save to an SRF file
	SRFfile = GetFilePath ("default name" ,"srf", CurDir(),"Save SRF File",2)

End Sub
