DEFINE_VAR_TABLE

The command can be used to set up a look-up table in the script. Once the table is set up, you can use a DEFINE_VAR command to set up a script variable by looking up a value in the table. It can also be used in a variable loop with VAR_LOOP_START...VAR_LOOP_END. The data that makes up the table can be specified inline, or read from a CSV file. Global Mapper assumes that the first line of the data contains the column names for the table. This is true regardless of whether the data is inline or in a file.

The following parameters are required by the DEFINE_VAR_TABLE command.

  • NAME - Defines the name of the table
  • FILENAME - (optional) Provides the full path to the CSV file that contains the table data. If both a file name and inline data are provided, only the data from the file is used; the inline data will be ignored.
  • HAS_COL_NAMES - specifies whether or not the first line of data contains column names. Enabled by default, use HAS_COL_NAMES=NO to specify that there are no column names. This is typically used for a simple list of values to loop over using VAR_LOOP_START...VAR_LOOP_END.

  • PROMPT - allows defining the values in the table by prompting the user to select a list of multiple items. The following values are supported:

    • FILE - Prompts the user to select one or more files that will be used as the values in the table with a column name of FILENAME. If you wish to instead use the contents of a prompted-for file, use a DEFINE_VAR command prior to the DEFINE_VAR_TABLE to prompt the user for the filename, then pass that in directly as the FILENAME parameter with no PROMPT=FILE. The PROMPT_TEXT value will be the title of the file open dialog. The FILENAME value (if any) will be the default filename selection (can be full path to provide a default folder too). You can use the FILENAME parameter to provide several defaults, including default folder, default filename, and/or default file extension. If you just want to provide a default folder, use FILENAME="C:\PATH_HERE\." where the filename is just a dot.

  • PROMPT_TEXT - specifies the text to show if a PROMPT parameter is provided

  • ABORT_ON_CANCEL - specifies that if a prompt is cancelled (like for a file) that the entire script should be aborted. Defaults to YES if a cancellable prompt is provided. Use ABORT_ON_CANCEL=NO to not cancel the whole script on cancel of prompt.

END_VAR_TABLE

- Indicates the end of the DEFINE_VAR_TABLE command. This is always required, whether the data is specified inline or in a file.

SAMPLES

Example (data specified inline):

DEFINE_VAR_TABLE NAME="state_codes"
   st_code,st_abb,st_name
   06,ca,"california,xyz"
   08,co,colorado
END_VAR_TABLE
DEFINE_VAR NAME="st_abb1" VALUE_TABLE="state_codes" VALUE_COLUMN="st_abb" \
COMPARE_STR="st_code=06"
DEFINE_VAR NAME="st_name1" VALUE_TABLE="state_codes" VALUE_COLUMN="st_name" \
COMPARE_STR="st_code=06"

Example (data in a file):

DEFINE_VAR_TABLE NAME="state_codes" \
FILENAME="C:\Temp\GlobalMapperWorkspaces\test_tabl e.csv"
END_VAR_TABLE
DEFINE_VAR NAME="st_abb5M" VALUE_TABLE="state_codes" VALUE_COLUMN="st_abb" \
COMPARE_STR="st_code=09"
DEFINE_VAR NAME="st_name5M" VALUE_TABLE="state_codes" VALUE_COLUMN="st_name" \
COMPARE_STR="st_code=09"

The example CSV file contains the following data:

st_code,st_abb,st_name
06,ca,"california,xyz"
08,co,colorado
09,me,maine

For an example that specifies a table of settings to use in a tool see Sample Script: Loop Over Settings