Global Mapper v25.0

Script command to select file or folder?

BillB
BillB Global Mapper UserTrusted User
edited May 2013 in GM Script Language
Hi, sorry if the following betrays a complete misunderstanding of GM scripting, but it seems that all import/export of files within the script language is hard-coded. That is, names and paths are stated within the script, which may be fine most of the time. Based on how AutoHotkey (Windows scripting language) works, I was wondering if the following exists or could be created.



FileSelectFile

Displays a standard dialog that allows the user to open or save file(s).


FileSelectFolder
Displays a standard dialog that allows the user to select a folder.




Many thanks

Bill

Comments

  • global_mapper
    global_mapper Administrator
    edited May 2013
    Bill,

    There is currently support for prompting the user when using DEFINE_VAR. You use the PROMPT parameter to specify the type of prompt and the PROMPT_TEXT to specify the text of the prompt. There isn't currently a prompt option that shows the file open dialog or a folder select dialog, so you would have to manually enter those as text. I might be able to add those though as special prompt types.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • BillB
    BillB Global Mapper User Trusted User
    edited May 2013
    That would be useful, Mike. I would have thought that filename/path would be one of the most regularly-changed variables, changing with each project, whilst the actual process you want to carry out with the script is probably common to multiple projects. Easy file/folder selection would enable simple re-use of common scripts.

    Something like:
    DEFINE_VAR NAME="IMPORT_FILENAME" FILESELECT
    IMPORT FILENAME=%IMPORT_FILENAME%

    Thanks

    Bill
  • global_mapper
    global_mapper Administrator
    edited May 2013
    Bill,

    I went ahead and added these. Now you can use PROMPT=FILE or PROMPT=DIR to prompt for a file or directory. Here is a sample:


    // Prompt for folder to load
    DEFINE_VAR NAME="DIR_TO_LOAD" PROMPT="DIR" VALUE="d:\temp\export test\" ABORT_ON_CANCEL=NO

    // Prompt for .zip file to load in folder. Cancel if nothing selected.
    DEFINE_VAR NAME="FILE_TO_LOAD" PROMPT="FILE" VALUE="%DIR_TO_LOAD%.zip" ABORT_ON_CANCEL=YES

    // Load the file.
    IMPORT FILENAME="%FILE_TO_LOAD%"

    I have placed a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper14.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v14.xx installation folder to give it a try. If you are using the 64-bit v14 version there is a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper14_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • BillB
    BillB Global Mapper User Trusted User
    edited May 2013
    Thank you Mike, customer service above and beyond the call of duty - but very nice to be the recipient :)

    We'll try these with our current export scripts. Excellent!
  • RobertR
    RobertR GlobalMapper Fan! Trusted User
    edited May 2013
    I just tried it out and it works like a charm. Very useful indeed, especially when you want to share the script with other users that need the same thing done, but have data located in a different path.

    Browsing through the numerous files I have, I wondered if it would be a nice addition to add custom icons for .gms and .gmw files [for eg like audio players use different icons for playlists, mp3file(s), cue files but still they preserve the form of the default program icon]. GM could have the default blue globe for associated file type(s), a red colored globe for .gms, and a green colored globe for .gmw (just an example to clarify what I mean). In this way you could easily spot the file types.

    snip.PNG

    I often clicked by mistake (and run) a .gms script when I wanted to open a gmw file, or a shapefile (this was the case when I selected to open .gms file with GM by default). Like in the example above, it is easy to see that I open the prj file with notepad, shp file with GM, dfb files with OOffice.
  • global_mapper
    global_mapper Administrator
    edited May 2013
    Robert,

    I think that users can customize the icon used for different file types. I haven't ever looked into it though. I would think you would almost want a single one most of the time so that you know they are Global Mapper files rather than needing to distinguish which type of Global Mapper file it is.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation