Writing Scripts
From Geoqo
One of GeoQO's most powerful features is its scripting ability. Scripts let you execute any of the geoqo features within one file.
Contents |
Scripts can do anything GeoQO can do
Take a simple example of needing to display a list caches Yamar owns. You can do this by writing the following script.
%search cache:owner_name=Yamar %display list
If you take the above and put it in a file called "yamars" you can then run geoqo using the -x option to run the script:
geoqo -x yamars
This will produce the following two windows:
Scripts can do many things at once
Scripts work by taking the results of a search expression and acting on it any way you want. Or multiple ways. Lets extend our example above to not only display a list, but also to export it to a gpx file:
%search cache:owner_name=Yamar %display list %export test.gpx
When you run the above, you'll not only see a displayed list but it'll also create a test.gpx file.
Scripts can have mulitple types of the same section
Exporting a search to multiple file formats:
%search cache:owner_name=Yamar %export test.gpx %export test.html
Scripts have auto-gui support
One of the most powerful features is that scripts can be created to prompt you for information. As an example, lets change the above to replace Yamar with an expression that will turn that part of the script into a parameter:
%search cache:owner_name=%[ownername,Yamar,text=Enter a Cache Owner Name:] %export test.gpx
Now when you run this script, it'll prompt you for a name to fill in and the default will still be set to Yamar:
Parameter specification syntax
The syntax for specifying parameters looks like:
%[NAME,DEFAULT,OPTIONS]
DEFAULT is the default value placed into the GUI screen. OPTIONS is fairly complex, but consists of any number of name=value pairs.
The NAME field is used to refer to things later on as well. For example, you could set the export file name to the entered name as well:
%search cache:owner_name=%[ownername,Yamar,text=Enter a Cache Owner Name:] %export %[ownername].gpx
Note that only the first call needed the extra DEFAULT parameter and extra OPTIONS.
Advanced Scripts
You can do many things with the OPTIONS section, including specifying the widget types, making menus with a list of values, etc.
You can also perform any tasks that geoqo itself can do using the GUI or command line options. See the geoqo manual on the [scripting ability] details for further reading.
In fact, the entire geoqo GUI is actually built on internal scripts. What really happens when you run geoqo without any arguments is that it is effectively doing the same thing as:
geoqo -x gui
Go ahead. Try it! Then, take a look at the scripts/gui file to see what it's doing internally. You'll see that's a top level file that displays buttons and calls other script files when they're pushed. Wheee......
Other Pages with Scripting Examples
See the scripting category page below for other pages that have example scripts on them:


