Global Mapper v25.0

Scripting new instance of gm

Ice Age Mark
Ice Age Mark Global Mapper UserTrusted User
edited December 2012 in GM Script Language
Hello Mike,


In V13 I set up a group of points on a background map that were all of the webcams in my region, with an attribute that was the address to a really simple GM script that would open the image URL and make various adjustments to enlarge, crop, enhance, etc. I would click on the point, choose the script address and choose "open as a file in GM", and a new instance of GM would open with my customized (and much improved) webcam image. Then I could just close that instance and do it again. It was pretty slick. I use it mostly to check for local snowfall so I haven't used it since V14 came out. Now the script opens the images in the same instance. This doesn't work out because the images aren't georeferenced and, at the least, must remain in geographic projection.


I'm sure the change was for the best, so I'm wondering how I might modify the scripts to work as they once did. EMBED_SCRIPT seems like the ticket, but how do I get a new instance to open? I know I'm always abusing GM with unintended and unconventional uses, but if you could steer me to the best way of accomplishing what was a cool setup, I would really appreciate it. I know I can access the URL directly as an attribute now, and I may have to settle for that, but it's the adjustments that the script makes that made it so much nicer.


Thanks again,


Mark

Comments

  • global_mapper
    global_mapper Administrator
    edited December 2012
    Mark,

    What does your attribute value show? Just the script filename? If so you might add the .exe path with the .gmw as a parameter and see if that works. I can't think of anything in Global Mapper that would have changed this behavior between v13 and v14 though. However the 'Open in GM' would have always opened in the current GM instance. The 'open with Windows' option would launch the associated app (usually GM) with the parameter being passed to it. Maybe that is all you need to do?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike,


    As usual, you were correct, sir. I guess some of my script files got unassociated with GM14 in Windows somehow. I fixed "always open with" for all of them and everything is good now.


    I was also wondering if, at your convenience, the SKIP_UNLOAD_ALL parameter for EMBED_SCRIPT could also be added to the UNLOAD_LAYER command as e.g. SKIP_UNLOAD_LAYER. This would be great for scripts I have set up for radar and other frequently updating weather maps. The first time they run there is always no layer to unload, but I want it there after that.


    I've been a map and science geek for 50 years, and Global Mapper is the greatest!


    Many thanks again,


    Mark
  • global_mapper
    global_mapper Administrator
    edited December 2012
    Mark,

    I updated the SKIP_UNLOAD_ALL parameter to skip the first UNLOAD_ALL or UNLOAD_LAYER command encountered in the embedded script. Let me know if that works or if you need a separate parameter (i.e. you have both UNLOAD_ALL and UNLOAD_LAYER, which seems unlikely). I have placed a new build at http://www.globalmapper.com/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.globalmapper.com/global_mapper14_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Howdy Mike,

    I guess I'm not understanding this now. There isn't an EMBED_SCRIPT command in my scripts; I was thinking that SKIP_UNLOAD_LAYER="YES" would be a parameter for the UNLOAD_LAYER command; LIKE the "skip unload all" parameter for "embed script". But since you know what you're doing, and I don't, I tried to go ahead and include the (unnecessary) embed script, but that isn't working out. Do I need EMBED_SCRIPT in the script, or did I just explain my request poorly? If it needs to be there to use the parameter that goes with it, how would I script that in when I don't need it? Sorry for being such a Computard.

    Thanks for the help,

    Mark
  • global_mapper
    global_mapper Administrator
    edited December 2012
    Mark,

    I'm not sure how the SKIP_UNLOAD_LAYER parameter would work. If you wanted to skip it wouldn't you just not add the UNLOAD_LAYER command?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike,

    It would only skip "unload layer" the first time through, like with embed script (I think). The issue is that with frequently updating sources like radar (~8 min.), the UNLOAD_LAYER needs to be there or the radar layers just keep accumulating, which I don't want; I just want the most recent one. I can delete them manually, but the script will do it for me with each new load. I'm really just trying to eliminate the error message and extra click when the script runs the very first time; because the first time there is never a previous radar layer to unload. I guess I actually mean SKIP_FIRST_UNLOAD_LAYER; or (more likely in my case) there is some simpler or better way (or another command) to accomplish this that I'm not seeing.

    Thanks much,

    Mark
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike, I think I mis-perceived the "...skip the first..." wording of the script help as the "first" time the script is run. The script can't know it was run previously each time it is run. It can only tell that there is no layer present to unload. So sorry to waste your time, however the parameter you added to EMBED_SCRIPT seems like it could still be useful for that command. I don't suppose there is any way to skip that first time error message that requires a response, as might be necessary using the SDK to do this?


    Thanks,


    Mark
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike,


    Well, I figured out the barbaric way (just my style) to do it. I just set up my backgrounds with an existing "dummy" layer that is an invisible, sub-pixel sized, same colored, area feature with the same layer name as the pending radar import. So the layer is already there thus skipping the error message, and the script replaces it with the radar download.


    Thanks so much for your always patient help,


    Mark
  • global_mapper
    global_mapper Administrator
    edited December 2012
    Mark,

    Ah I understand now, it does sound like you worked out that the parameter wouldn't make sense as the script doesn't know it was run earlier. I wonder if you could use SET_LOG_FILE at the start of your script to have the messages just go to a log file. Or I could add a parameter to hide any error messages.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike,

    Using SET_LOG_FILE FILENAME="C:\...\LOG ERROR FILE" as is, at the beginning, didn't work. If there could be a way to skip or hide the error message in the script, or send it to a file, that would really be a lot easier than fixing all of my backgrounds with my "dummy" method.

    Thanks,

    Mark
  • global_mapper
    global_mapper Administrator
    edited December 2012
    Mark,

    I have added support for adding SHOW_WARNINGS=NO to the GLOBAL_MAPPER_SCRIPT header line at the start of your file to disable showing messages prefixed with WARNING at the end of your script run. True errors will still show. I have placed a new build at http://www.globalmapper.com/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.globalmapper.com/global_mapper14_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Ice Age Mark
    Ice Age Mark Global Mapper User Trusted User
    edited December 2012
    Mike,


    Perfect! Thank you very much, sir. I have almost two dozen of these frequently updating weather overlays of various sorts that I use; so this really streamlines it. GM is the most versatile GIS program in the universe.


    Best regards,


    Mark