topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Wednesday December 11, 2024, 9:42 pm
  • Proudly celebrating 15+ 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: alias with parameter  (Read 4676 times)

goddert

  • Participant
  • Joined in 2015
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
alias with parameter
« on: January 15, 2016, 03:15 AM »
Hi,

I did configure a simple alias which takes a parameter to launch a script

alias trigger: proxy

Regular Expression pattern: ^proxy (.*)$

Script:
cntlm | c:\bin\proxy-set.bat "$$1"
ccproxy | c:\bin\proxy-set.bat "$$1"
off | c:\bin\proxy-set.bat "$$1"

Using the alias with a parameter works fine. Instead when I use the cursor to choose manually one of the three options (cntlm, ccproxy, off) how do I pass my choice to the script proxy-set? Preferably as string (cntlm, ccproxy, off).

I did search but couldn't find the right topic. Or maybe I did use the wrong search strings.

Thanks in advance for any help.

Goddert


wjamoe

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 99
    • View Profile
    • Donate to Member
Re: alias with parameter
« Reply #1 on: January 15, 2016, 11:24 PM »
This should work:

alias trigger: proxy
Regular Expression pattern: ^proxy\s+(.+)$

Script:
proxy cntlm | c:\bin\proxy-set.bat "cntlm"
proxy ccproxy | c:\bin\proxy-set.bat "ccproxy"
proxy off | c:\bin\proxy-set.bat "off"
proxy $$1 | c:\bin\proxy-set.bat "$$1"

Each line includes a fixed parameter on the right side.

I modified the regex, the parameter is now optional.

The last line is optional, it will allow you to specify a different proxy parameter to the bat file.
For readability I added 'proxy' at the start of each line, this is not mandatory.
but for the last line it is kind of essential, it would otherwise only show your typed parameter in the search result list (depending on your farr display options/report columns).

goddert

  • Participant
  • Joined in 2015
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: alias with parameter
« Reply #2 on: January 18, 2016, 02:31 AM »
Thank you very much!

Your solution works fine ... partly  :)
Choosing with the cursor obviously FARR takes the selected option and launches the script with the corresponding parameter.

Instead if I write the parameter in the FARR window FARR doesn't pass the written parameter to the script but FARR takes always the first of the options. In my case the option with cntlm. E.g., I write "proxy foo" nevertheless FARR executes the line c:\bin\proxy-set.bat "cntlm".

I have to investigate why (btw FARR shows the parameter as I'm writing it but for a reason unknown chooses the first line)

Anyway thanks again.

Goddert

wjamoe

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 99
    • View Profile
    • Donate to Member
Re: alias with parameter
« Reply #3 on: January 18, 2016, 02:41 PM »
it looks like either

the farr option ' stop at first exact match' is enabled in options search behaviour.

or you enabled 'always launch first result on hitting enter' within keyboard interface

I won't be able to reproduce all the possible combinations of farr settings, so here you are on your own.

if it always takes the first line, you could try moving my last line to the top line

(are you sure you disabled all other aliases matching 'proxy' ?)