Jump to content

open txt file for read


Recommended Posts

I wrote a WEng script, which reads a text file with some coordinates and wind data. The user should select the file name in the Windows "open file" window.

At the moment I am using
FileAssistant.GetAWindAtlasFileName

This works, but for this command *.map files are preselected. The user has to select *.* manually.

Is there any other command to select *.* or *.txt files directly?

Thanks,
Uwe
Link to comment
Is the default extension for that method really *.map or is it actually *.lib? If it's map then we've got a bug in there somewhere.

There is no method on that object (or anywhere else) to get the name of some other type of file. You could use the VBScript call 'Inputbox' to retrieve a string from the user, but that's a bit ugly.

We could add a method like this to the next WEng 2.0 release if you think it would be useful.

Duncan.
Link to comment
Thanks for the response. You're right, it's *.lib.

I think it would be a great help to have a method like
FileAssistant.GetAFileName Extension
in WEng. Extension should be a free definable string (could be "*.txt", "*.grd", "*.rsf", ...).
Link to comment
I've had success using the below method to get the filename of txt files. You can add your own filters to the open dialog:

'Open File Dialog ang get the filename that was picked

Dim objDialog

'Create a dialog object
Set objDialog = CreateObject( "UserAccounts.CommonDialog" )

'Filter so only txt files are shown
objDialog.Filter = "Mast Siting Files|*.txt"

'Open the dialog and return the selected file name
If objDialog.ShowOpen Then
GetFileName = objDialog.FileName
Else
GetFileName = ""
End If


Then your filename will be in the GetFileName variable.
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...