Global Mapper v24.1

Prompt for select a layer

derf
edited February 2016 in GM Script Language
Hi, 
Is it possible to prompt the user for select a user defined layer.

I mean :

hide all layer (layer loop should be ok ),

retrieve layer names (or not possible ?)

prompt user for a layer_name (define variable) ,

unhide only the provided layer_name layer ?

I am just discovering GM scripting... Great but not always easy ...

Thanks in advance for replies.



Answers

  • bmg_bob
    bmg_bob Global Mapper Programmer
    Hello,

    Global Mapper scripting does not have a function to prompt the user to choose one of the currently loaded layers.  You can prompt the user to type in a string and match it against one of the layer variables that is available within the layer loop.

    Another option is to prompt the user for a file name, and then import the selected file, but that is not the same thing, of course.

    Cheers,

    Bob
  • bmg_bob said:
    "You can prompt the user to type in a string and match it against one of the layer variables that is available within the layer loop."

    Thank you for your answer.

    This could help me, is there any example somewhere of this kind  "string matching within layer loop ?

  • bmg_bob
    bmg_bob Global Mapper Programmer
    Here is an example:

    // Prompt for file name without extension
    DEFINE_VAR NAME="LAYER_TO_USE" PROMPT=YES ABORT_ON_CANCEL=YES \ PROMPT_TEXT="Type the name of a layer:"
    // Loop over the loaded layers, do something for the selected layer
    LAYER_LOOP_START FILENAME="*"    
        IF COMPARE_STR="%LAYER_FNAME_WO_EXT%=%LAYER_TO_USE%"
           // Do something...
        END_IF
    LAYER_LOOP_END
    Cheers,
    Bob
  • Many many thanks