Next: Redirecting the command output, Previous: Querying project switches, Up: Executing external tools
Another solution to query the arguments for the tool is to ask the user interactively. The scripting languages provides a number of solutions for these.
They generally have their own native way to read input, possibly by creating a dialog.
In addition, the simplest solution is to use the predefined GPS commands for this. These are the two functions:
yes_no_dialoginput_dialogFrom the GPS shell, it is only convenient to query one value at a time, since it doesn't have support for lists, and would return a concatenation of the values. However, this function is especially useful with other scripting languages.
The following is a short example that queries the name of a directory and a file name, and displays each in the Messages window.
<?xml version="1.0" ?>
<query_file>
<action name="query file and dir">
<shell lang="python">list=GPS.MDI.input_dialog \
("Please enter directory and file name", "Directory", "File")</shell>
<shell lang="python">print ("Dir=" + list[0], "File=" + list[1])</shell>
</shell>
</action>
</query_file>