Website Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 31, 2015, 05:55:12 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Need help with optional parameters in aliases  (Read 6184 times)

diesalher

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Need help with optional parameters in aliases
« on: April 22, 2009, 08:46:11 PM »
Hi, i'm trying FARR and i need a bit of help. First of all, sorry for my english, not my home lang.

Actually i'm trying to migrate from Launchy to FARR but, it's a bit more difficult than i though.
I mainly use Launchy for one thing, the Runny plugin.

I  use runny to invoke a program with a variable number of parameters so, in Launchy i simply type..

rtm [TAB] param1 [TAB] param2 [TAB] param3

and it invokes my program with the 0,1,2 or 3 parameters that i've typed
eJ C.\Program Files\rtm\rtm.exe param1 param2 param3

i think in farr this behavior is acomplished using alias with Regex but i'n no xpert in using Regex.

How can i acomplish the same behaviour? note that i could not enter parameters, or only 1 or 2 or the whole 3 .
I achieve to invoke the program with 3 params but no with 2 using a single regex..

anyway.is there any help with the expressions used in aliases?

thanks in advance.



mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #1 on: April 22, 2009, 09:00:58 PM »
you know i'm really embarrassed to say this, but farr should have a much easier way to pass arguments to programs.

as you say, you could do it by setting up an alias with a regular expression, but i think the solution, which has been discussed previously on the forum, is to define a universal separator character that someone can type to indicate that what follows is an arguement string to pass to whatever is being launched.

let me implement this today or tomorrow, and then we can debate about tweaks to what i implement, like what character we should use as the separator.

my inclination is to use something like:

normal search terms :: arg1 "arg two" arg3

so the :: means that whatever follows are commandline arguments.
the arguements are space separated, with double quotes enclosing single arguements that have spaces.

seem reasonable?

diesalher

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #2 on: April 23, 2009, 03:30:41 AM »
Yes, seems very reasonable althogh i'm more inclined to use another separator like TAB
which never is user in a parameter, is only one keypress and helps me avoiding to use
"" which is a bit more usable in a NetBook.

So program [TAB] arg1a arg1b [TAB] arg2   --->   program "arg1 arg1b" arg2             Ultra fast to type

i suposse it should be nice if every user could choose his favorite separator.

Thank you very much

nitrix-ud

  • Charter Member
  • Joined in 2005
  • ***
  • gravatar avatar
  • Posts: 483
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #3 on: April 23, 2009, 07:08:00 AM »
i still think the best would be a separate "box" for arguments or modifiers...

SlimShady

  • Supporting Member
  • Joined in 2008
  • **
  • gravatar avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #4 on: April 23, 2009, 07:24:20 AM »
I vote for the :: method. Seems fine. As long as you can type anything on the right side, it's great.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #5 on: April 24, 2009, 01:35:33 AM »
Implemented but not yet uploaded (i actually used ++ instead of :: because it's simpler to keep using + sign for modifiers).
For example:
Code: [Select]
ping ++ www.donationcoder.com -n 2
Seems to work well and its LONG overdue.

I just have to test my recent variable replacement bugfix to make sure i didn't break anything before I upload.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #6 on: April 24, 2009, 01:36:50 AM »
Note1: you dont actually need the space AFTER the ++ but you do need it before the ++.
Note2: you can use this ++ method both on programs launched via explicit directory browsing, and on those contained within alias results.
Note3: ++ specified arguments will be ADDED to any existing arguments, so you can combine them.
Note4: An alias can even specify WHERE exactly in the argument list they should go by using %comlineargs% in the launch string.  This makes the ++ technique a very simple way of passing optional info to a non-regular expression alias.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #7 on: April 24, 2009, 04:33:51 AM »
new version is up, give it a try and let me know how it works for you.

diesalher

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #8 on: April 24, 2009, 05:42:42 AM »
Seems to work fine  :D

Thank you very much for this update. Lightning fast.

NOTE:i still find the Launchy method to handle optional parameters faster and a bit more usable, but the low resources and no indexing of FARR is a winner. I think i can get used to use "", or maybe use autohotkey to do it for me :) (in my netbook i hate use "" and i'm a bit fanatic of the minimum effort policy)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #9 on: April 24, 2009, 05:58:45 AM »
im open to other ways to handle arguments with spaces.. it's just that tab is out of the question since it's used differently in farr.

we could use an option that says that arguments are separated by some other character, and farr can auto quote args with spaces.

for example, we could have it so that if you type:

notepad ++ arg string 1 ++ arg string 2 ++ arg string 3

farr would pass that as

notepad "arg string 1" "arg string 2" "arg string 3"

diesalher

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #10 on: April 24, 2009, 06:31:46 AM »
That'll be perfect, because then i could use AutohotKey to intercept the TABS (or another free key in my keyboard) and replace them with ++ when FARR is active. Anyway thanks again for your help, your support is impressive.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 218
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #11 on: April 24, 2009, 01:46:53 PM »
im open to other ways to handle arguments with spaces.. it's just that tab is out of the question since it's used differently in farr.

is tab doing anything that i am missing? it autocompletes the text, right? if it's all it does why couldn't it be like launchy? autocomplete plus a separator for the arguments?
It is impossible to make anything foolproof because fools are so ingenious.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #12 on: April 24, 2009, 10:41:21 PM »
Quote
is tab doing anything that i am missing? it autocompletes the text, right? if it's all it does why couldn't it be like launchy? autocomplete plus a separator for the arguments?

this could be done.. tab would autocomplete and then add the ++ for you automatically so you could put some optional commandline options.  certainly i could add an option for this at the very least.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 218
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #13 on: April 25, 2009, 03:09:41 AM »
this could be done.. tab would autocomplete and then add the ++ for you automatically so you could put some optional commandline options.  certainly i could add an option for this at the very least.
If that could be done, could a special character separator be used instead of the ++? something like ►, » or •? I am thinking that the user never has to type it, because we can use tab to autocomplete and add a separator, so why not use a character that is IMHO visually clearer?

I am thinking also if multiple parameters are needed you could just keep pressing tab to insert aditional separators. And I am not sure if this is needed in file browsing mode.....
It is impossible to make anything foolproof because fools are so ingenious.
« Last Edit: April 25, 2009, 03:15:38 AM by skajfes »

diesalher

  • Participant
  • Joined in 2009
  • *
  • Posts: 5
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #14 on: April 27, 2009, 05:21:22 AM »
I've testing it more and i think i have a problem

I use this regular expression : ^rtm|gtd

I type rtm ++ arg1 ++ arg 2

the arg1 my program receives is "++ . arg1"

EDIT : My fault, i didn't realize that the ++ as parameter separator is not implemented in current release.
typing rtm ++ arg1 arg2 arg3 works fine.
« Last Edit: May 05, 2009, 04:56:09 AM by diesalher »

kreatorr

  • Participant
  • Joined in 2008
  • *
  • gravatar avatar
  • Posts: 15
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #15 on: June 12, 2009, 11:23:12 PM »
Just discovered this undocumented feature with the recent release.  It's exactly what i've been looking for. 

Can this be further improved so that once ++ or whatever special character has been activated, the incremental search can kick in for the new parameters, i.e. file browsing mode to allow launching a program with a file as its parameter?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #16 on: June 12, 2009, 11:31:47 PM »
Quote
Can this be further improved so that once ++ or whatever special character has been activated, the incremental search can kick in for the new parameters, i.e. file browsing mode to allow launching a program with a file as its parameter?

can you elaborate?

kreatorr

  • Participant
  • Joined in 2008
  • *
  • gravatar avatar
  • Posts: 15
    • View Profile
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #17 on: June 19, 2009, 04:48:31 AM »
Actually, I might be misunderstanding this feature, as it is about adding parameter values when calling up aliases.  I was confusing this with the proposed feature of handling objects and actions as covered in some previous discussions:

http://www.donationc...ex.php?topic=11487.0
http://www.donationc...dex.php?topic=2277.0
http://www.donationc...dex.php?topic=3713.0

This would be a specific use-case where the 'action' is actually an implicit "Launch X, with Y as a parameter" when "X ++ Y" is entered.  For example, I'm trying to launch notepad with a file that is within FARR's search paths.  Ideally, I'd like to be able to type "no" and then have notepad appear on the list, type tab, to complete it, followed by "++".  Typing "myt" will then find a file called mytext.txt in the search paths.  Essentially after typing ++, it starts a new search based on what ever is typed after the "++".  Everything before the "++" is assumed to be a valid launch item (whether it be a path to an executable or an alias), and not included in the new search.  When that file shows up in the search list, type tab again if it's the first item to autocomplete resulting in something that looks like this in the FARR entry box :

C:\WINDOWS\system32\notepad.exe ++ C:\somesearchpath\mytext.txt

Hitting enter should then open notepad with mytext.txt as the parameter. 

Anyway, will look forward to mouser implementing the object -> action feature one day.  For now, being able to to launch items with parameters added on the fly is a good start! :)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,933
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
Re: Need help with optional parameters in aliases
« Reply #18 on: June 19, 2009, 06:22:54 AM »
kreator, you've accurately described the situation -- and you are right that the object-action ideas would be what would let you do what you want if/when those are implemented.