LAYER_LOOP_START
The LAYER_LOOP_START command begins a loop of commands over load layers. You can loop over all layers or just those matching a particular filename mask. You end a loop over the files in a folder using the LAYER_LOOP_END command. Note that it is also possible to nest loops.
Built-in Variables
For any commands found within a LAYER_LOOP_START...LAYER_LOOP_END pair defining a loop, the following special character sequences (the LAYER part can be changed using the VAR_NAME_PREFIX parameter) can be used anywhere (examples of what the values will be based on a current layer filename of 'C:\data\my_file.dem' are listed):
- %LAYER_DIR% - full path to current file (value is 'C:\data\')
- %LAYER_FNAME_W_DIR% - full path and filename of current file (value is 'C:\data\my_file.dem')
- %LAYER_FNAME% - filename of current file (value is 'my_file.dem')
- %LAYER_FNAME_WO_EXT% - filename of current file without extension (value is 'my_file')
- %LAYER_PARENT_DIR% - name of parent directory of file (value is 'data')
- %LAYER_DESC% - description of current layer
The following parameters are used by the LAYER_LOOP_START command.
- FILENAME - filename or description of layer(s) to loop over. This can include * and ? wildcard characters. If you leave the FILENAME parameter off then all loaded layers will be looped over, which is the same behavior as using FILENAME="*". If you specify a blank FILENAME parameter then you will loop over all layers not based on a file. When running the script in the context of the main map view (including loading a workspace) you can also pass in the value 'USER CREATED FEATURES' to have the 'User Created Features' layers looped over or 'SELECTED LAYERS' to have any layers selected in the Control Center looped over.
- VAR_NAME_PREFIX - prefix to use for the variable names in the loop (useful in nested loops). For example if you provided VAR_NAME_PREFIX="HIDE", then you would use %HIDE_FNAME% rather than %LAYER_FNAME% inside that loop. If you don't provide a value then the default of LAYER is used.
LAYER_LOOP_END
The LAYER_LOOP_END command ends a loop of commands over loaded layers. See the LAYER_LOOP_START command for details.
SAMPLE
GLOBAL_MAPPER_SCRIPT VERSION="1.00" // Hide all layers LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE" SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=YES LAYER_LOOP_END // Loop over the loaded layers, doing a separate export for each LAYER_LOOP_START FILENAME="*" // Enable the current layer since we hid it above SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO // Export EXPORT_RASTER FILENAME="%LAYER_DIR%%LAYER_FNAME_WO_EXT%_loop.tif" FORMAT=GEOTIFF // Disable the current layer so it won't be involved in other operations SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES LAYER_LOOP_END // Unhide all layers LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE" SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=NO LAYER_LOOP_END