Follow

How can I prompt a user for a file path in a Surfer script?

The GetFilePath function permits to ask the user for a specific file. I am trying to find a way to open a dialog asking for a specific directory.

 

The easiest way is to use an InputBox, where you would enter the entire path manually.

    FilePath$=InputBox$("Enter file path. For example, C:\Users\<your username>\Desktop\", "File Path", "")
    If FilePath$ ="" Then End If     Len(FilePath$)-InStrRev(FilePath$,"\") <> 0 Then FilePath$ = FilePath$ + "\"

 

Alternatively, if there are any files in the directory, you can use the CurDir function to select a file and then just save the path to that file.

    filename = GetFilePath(" ","DAT;TXT;CSV;XLS",CurDir(), "Select file in desired directory", 0)
    FilePath$ = CurDir(filename)
    If FilePath$ ="" Then End If Len(FilePath$)-InStrRev(FilePath$,"\") <> 0 Then FilePath$ = FilePath$ + "\" Debug.Print FilePath$

 

If you decide to use the latter option, you would just change the "DAT;TXT;CSV;XLS" in that first line to the file extension of the file in the desired directory.

 

Both of these options are BASIC Automation options, which are not specific to Surfer. You can click Help | BASIC Language Help from within Scripter to find various help topics about these BASIC Automation options.

 

Updated June 15, 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.