Author Topic: SEARCHING with Multi Commander  (Read 48623 times)

loveofgaia

  • Newbie
  • *
  • Posts: 2
    • View Profile
SEARCHING with Multi Commander
« on: September 07, 2013, 12:20:33 »
I've got a question about aliases.
I wanted to create a shortcut "w" for searching in Wikipedia (for example: "w cat" would look up for "cat" i Wikipedia). But I failed miserably.
How a query like this should look like in MC? I've created "test search"  query in Wikipedia and got this:
newbielink:http://en.wikipedia.org/w/index.php?title=Special:Search&search=test%20search&button= [nonactive]
then I tried to replace "test%20search" part with something else ("?q", "$$1" etc.) but it didn't work.

So my question is: what should I do and how to create other aliases like that (I want to be able to create my own for Polish Wikipedia, Google Images, Wikimedia Commons and other sites).

Thank you in advance for your help,
LoveOfGaia

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4492
    • View Profile
    • Multi Commander
Re: SEARCHING with Multi Commander
« Reply #1 on: September 07, 2013, 13:21:45 »
I don't think you can do that with alias. Because alias replace one command with another. And the parameters that is sent to the alias is sent as parameters to the replaced part. And since it is sent as a parameter there will be an extra space between the url and the parameter and that will not work.

But you can do it using script.

Create a UserDefinedCommand of MultiScript type that looks like this

Code: [Select]
@var $url = "";
$url = "http://en.wikipedia.org/w/index.php?title=Special:Search&search=" + $arg(0);
MC.Run CMD="{$url}" SHELL

When you save the script, the script will get a unique ID. (You see that id in the upper right location in the User commands dialog..
lets say it gets the id 77bbd54dec4b412589de6ea89b5d76c2  (You will get a totally different id)

Then in the alias editor you create an alias that calls that script by making "w" be an alias for "@77bbd54dec4b412589de6ea89b5d76c2"
( @ followed by the command id )

Now you can type "w cat" in the command line field


loveofgaia

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SEARCHING with Multi Commander
« Reply #2 on: September 07, 2013, 14:33:56 »
Thank you very much. That worked perfectly... but only with one word searching.
If I type "w john" - that's great. But if I type "w john locke" it only looks up for "john".
How can I change that and make it work for multi-word searching?

« Last Edit: September 07, 2013, 14:40:03 by loveofgaia »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4492
    • View Profile
    • Multi Commander
Re: SEARCHING with Multi Commander
« Reply #3 on: September 07, 2013, 14:48:49 »
you can loop all args and build up the query string. I do not know how wikipedia want to have the url but something like

Code: [Select]
@var $query = "";
@var $n = 0;
for( $n = 0; $n < $argcount; $n++ )
{
   if( $n > 0 )
   {
     // Add delimiter for every search word, depends on the website..
      $query = $query + "+";
   }
   $query = $query + $arg($n);
}
$url = "http://en.wikipedia.org/w/index.php?title=Special:Search&search=" + $query;

You might have to experiment a bit to get it right.
« Last Edit: September 07, 2013, 14:51:14 by Mathias (Author) »