Type in a command, or "ls dictionary" to search all commands for "dictionary", etc.

Advanced Syntax for Creating Commands

You probably already know that you can use %s to let the user specify parameters for your command. For example, if you make a command called gim with the following URL...
...when the user types...
gim porsche 911
...they will be taken to...
Below are some advanced tricks that you can use when making a new command. If you have any suggestions for advanced Yubnub syntax, send me an email.

Multiple Parameters

Finally Yubnub now has multiple parameters. This is best explained with an example. Andrew MacDaniel wanted to make a Google Local command called "gloc". Google Local takes two parameters: a "what" and a "where". You can now make such a command using the following URL:
Note the two parameters: ${what} and ${where}. So now people can type...
gloc -what pizza -where Poughkeepsie, NY
...and they will be taken to...
Neat, hey? Note the dashes on "-what" and "-where". This is a tribute to Yubnub's command-line heritage. In the command-line world, these are called "switches". "-what" and "-where" would be referred to as the "what switch" and the "where switch".

Default Values

Continuing our above example, what if the user doesn't specify a "what" or a "where"? There is now a way to specify default values (syntax suggested by Christopher Church).
http://www.google.com/local?sc=1&hl=en&q=${what=tennis shoes}&near=${where=Washington, DC}&btnG=Google+Search&rl=1
Now if the user does not specify a "what"...
gloc -where Poughkeepsie, NY
...it will default to "tennis shoes" and they will be taken to...
Similarly, if they do not specify a "where", it will default to "Washington, DC".

Converting GET to POST

Sometimes you can't turn a web submission form into a Yubnub command because it is a POST form (the source code says method="post") rather than a GET form (the regular kind). Well, Sean O'Hagan has made a way to create Yubnub commands from POST forms. All you have to do is include the following text somewhere in your URL: [post]

For example, here is the URL for the stlclib command, which searches the St. Louis County Library:
Thanks Sean for contributing the get2post.php script! (Source code)

Tip: It can be a headache to try to construct the URL by looking at the HTML source. So go to Stephen Ostermiller's bookmarklets and drag his "Forms To GET" bookmarklet to your toolbar. Then press it to convert the POST form to a GET form so you can see the parameters in your address bar when you submit it.

Update: Joshua H. reports that when using [post] you may need to replace your "&" with a "?": "I suspect that this wasn't noticed before because most search forms take more than one parameter and the important one with the search terms was not the first one in the list." Some commands need it to be "&" (like ibands); others need it to be "?" (like desa).

Using a Character Other Than + for Spaces

Normally Yubnub will convert spaces to + signs, like in the example above ("porsche 911" is converted to "porsche+911"). This is what most websites expect (like Google and Yahoo). But there are some websites that expect %20 instead of + signs -- for example, the National Library of Singapore. To tell Yubnub to use %20 instead of + for spaces, include the following text somewhere in your URL: [use %20 for spaces].

For example, if you make a command called nlb with the following URL...
http://vistaweb.nlb.gov.sg/cgi-bin/cw_cgi?10100+REDIRX+useDatabase_3002_w_%s[use %20 for spaces]
...when the user types...
nlb harry potter
...they will be taken to...
Note that Yubnub converted "harry potter" to "harry%20potter" instead of "harry+potter".

Update: You can now use other characters besides %20. For example, to use - signs, say [use - for spaces].

Turning off URL Encoding

Normally Yubnub will apply "URL encoding" to parameters. For example, "gim Mork & Mindy" gets turned into http://images.google.com/images?q=Mork+%26+Mindy (note that the & became +%26+). This is what works for most websites. However, W. Van Hooste pointed out that this does not work for the Internet Archive Wayback Machine. To tell Yubnub to turn off URL encoding, include the following text somewhere in your URL: [no url encoding]

For example, if you make a command called arch with the following URL...
http://web.archive.org/web/*/%s[no url encoding]
...when the user types...
arch http://www.ing.be/
...they will be taken to...
If you hadn't specified [no url encoding], the user would have been taken to http://web.archive.org/web/*/http%3A%2F%2Fwww.ing.be%2F

Combining Commands

You can now combine commands together. For example, g {random 100}.

Going to a Different URL Depending on Whether the User Supplies Parameters

Fuska has developed a technique for going to one URL if the user provides arguments, and another URL if they do not provide arguments. For example, you can make a command that takes you to the CNN search page if you specify keywords to search for, and if you don't specify any keywords, it will take you to the CNN main page. Fuska's technique uses Allen Ormond's ifthen command.

Positional Parameters

Fuska has also developed a technique for positional parameters e.g. gloc -what {% 1 %s} -where {% 2 %s}[no url encoding]

Switch Statements

Here's how to do a switch statement using the switch command:
http://www.gamefaqs.com/search/index.html?game=%s&platform={ switch ${plat} | xbox => 13, dreamcast => 1, * => 0 }
If plat is "xbox", the platform will be set to 13. If plat is "dreamcast", the platform will be set to 1. Otherwise the platform will be set to 0.