Prompt for select a layer

derfderf Posts: 3
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_bobbmg_bob Global Mapper Programmer Posts: 2,218
    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
  • derfderf Posts: 3
    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_bobbmg_bob Global Mapper Programmer Posts: 2,218
    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
  • derfderf Posts: 3
    Many many thanks
Sign In or Register to comment.