Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Output folder selection

73 views
Skip to first unread message

Richard Robinson

unread,
Oct 23, 2024, 6:46:06 AM10/23/24
to MapInfo-L
I wish to be able to select a folder for the output of a mbx to save results but am having difficulty in finding the appropriate MapBasic code. The nearest I have found  is the  FileOpenDlg("","","*.*","Output Location") command but this requires the selection of a existing file within the output directory!

Peter Horsbøll Møller

unread,
Oct 23, 2024, 7:52:21 AM10/23/24
to mapi...@googlegroups.com

You can use FileSaveAsDlg() to let the user specify a not-existing file.

This will also warn the user about overwriting a potential existing file.

 

Are you looking to le the user just pick the output directory?

This is useful if you create multiple outputs

 

Peter

 

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Richard Robinson
Sent: 23. oktober 2024 12:46
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Output folder selection

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

I wish to be able to select a folder for the output of a mbx to save results but am having difficulty in finding the appropriate MapBasic code. The nearest I have found  is the  FileOpenDlg("","","*.*","Output Location") command but this requires the selection of a existing file within the output directory!

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/9330321a-2f47-4869-a8cf-94f351467e30n%40googlegroups.com.

Richard Robinson

unread,
Oct 24, 2024, 4:51:59 AM10/24/24
to mapi...@googlegroups.com
Hi Peter,
Yes I’m just after the user selecting either an existing or new output folder. The file save as still requires a file to be selected and in the case of a new folder there will be no existing files.

Thanks for the assistance.

Richard

Sent from Outlook for iOS

From: 'Peter Horsbøll Møller' via MapInfo-L <mapi...@googlegroups.com>
Sent: Wednesday, October 23, 2024 12:52 PM
To: mapi...@googlegroups.com <mapi...@googlegroups.com>
Subject: RE: [MI-L] Output folder selection
 
You received this message because you are subscribed to a topic in the Google Groups "MapInfo-L" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mapinfo-l/r53-kSI3nDc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/BY1PR16MB6381B3CB5D4ABD0E8A152CC3964D2%40BY1PR16MB6381.namprd16.prod.outlook.com.

Peter Horsbøll Møller

unread,
Oct 24, 2024, 5:38:32 AM10/24/24
to mapi...@googlegroups.com

Hi

 

Try this:

 

  1. Download and place the FILELib.dll in the folder with your MBX.

 

You can find the DLL here in the MapBasic Common Library:

https://github.com/PeterHorsbollMoller/mbLibrary

 

The file FILELib.dll.def contains a listing of all the methods in the DLL:

https://github.com/PeterHorsbollMoller/mbLibrary/blob/master/FILELib.dll.def

 

  1. Include this declaration at the top of your source code:

 

Declare Method FILEBrowseForFolder

      Class "FILELib.Files"  Lib "FILELib.dll" Alias "BrowseForFolder"

      (       ByVal sDescription As String      'Text to display in the dialog

            , ByVal sFolder As String           'Start folder to use in the dialog

            ) As String

 

Or download the file FILELib.DLL.def from above to get access to more methods from the DLL and include this in your source code at the top:

 

Include "FILELib.DLL.def"

 

  1. In your code where you want the user to pick a folder, use this:

 

sPath = FILEBrowseForFolder("Select directory for output data...", sPath)

If sPath = "" Then

   Exit Sub

End If

 

Cheers

Peter Horsbøll Møller

unread,
Nov 4, 2024, 6:33:12 AM11/4/24
to mapi...@googlegroups.com

Hi Richard

 

I created this article going over some of the options for selecting files and folder:

https://community.precisely.com/discussion/mapbasic-monday-selecting-files-and-folders

 

Cheers

Peter

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: 'Peter Horsbøll Møller' via MapInfo-L <mapi...@googlegroups.com>
Sent: 24. oktober 2024 11:38
To: mapi...@googlegroups.com
Subject: RE: [MI-L] Output folder selection

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

--

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.

Richard Robinson

unread,
Nov 6, 2024, 4:48:46 AM11/6/24
to mapi...@googlegroups.com
Thanks Peter

Sent from Outlook for iOS

From: 'Peter Horsbøll Møller' via MapInfo-L <mapi...@googlegroups.com>
Sent: Monday, November 4, 2024 11:32:45 AM
You received this message because you are subscribed to a topic in the Google Groups "MapInfo-L" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mapinfo-l/r53-kSI3nDc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mapinfo-l/BY1PR16MB63810DB8AEDEBAE74B55D77096512%40BY1PR16MB6381.namprd16.prod.outlook.com.
Reply all
Reply to author
Forward
0 new messages