topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday December 12, 2024, 3:43 am
  • 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: How can I enter 2 seperate arguments?  (Read 9412 times)

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
How can I enter 2 seperate arguments?
« on: May 10, 2008, 11:30 AM »
Hi
I am having little issue here. I use $$1 and $$2 to pass 2 arguments to command line emailer. First one is an email adress second one is the title of email.
I can send email successfully If my title is just one word. If my title is more than one word Farr only passes first word of the title. I want Farr to pass the full title to emailer. I use
sendemail-tab-email adress-space-title(may contain spaces)

1000>>>sendemail>->sendemail $$1 $$2| PathTo\sendEmail.exe -s mail.mymail.com:2025 -xu [email protected] -xp password -t "$$1" -u "$$2" -f [email protected]>+>^sendemail (.+) (.+)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #1 on: May 10, 2008, 05:05 PM »
Try this as your regular expression:
^sendmail (\S*) (.*)

basically it just says that the first argument is a string of characters NOT INCLUDING ANY SPACES, so it ends at the first space.  then second argument gets the rest.

the problem with your original regular expression is that the first argument was eating up all the text on the line greedily except the last word.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #2 on: May 10, 2008, 05:05 PM »
by the way, remember that you can actually test the regular exression from the alias creation dialog, which is really helpful to see how the arguments are being parsed.

herojoker

  • Participant
  • Joined in 2008
  • *
  • Posts: 124
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #3 on: May 10, 2008, 05:12 PM »
As you know, the way texts are matched with the help of regular expressions is not necessarily unique!
Perhaps the regexp parsing engine is not greedy enough or too greedy.
@mouser: IMHO it should be set to greedy and it should be possible to set certain parts ungreedy with a "?", for example: "(.+?) (.+)" would try to make the first part of the match as short as possible (until the first space).

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #4 on: May 10, 2008, 06:24 PM »
Mouser thanks for suggestion ^sendmail (\S*) (.*)  this seem to work.

I have one more question. How come "tab" works for certain aliases and not for others? Some of my aliases accept tab to move to next argument some does not. This happens when I need to start creating 2nd argument. Tab does not work I need to use space. Maybe first one feels like it accepts tab becasue it is also part of autocompleting of the alias?


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #5 on: May 10, 2008, 06:28 PM »
Maybe first one feels like it accepts tab becasue it is also part of autocompleting of the alias?

exactly right.  tab is just autocompleting the alias name.

i was actually thinking at some point whether regex aliases should have an additional optional text which should be put into the search edit when user tabs or selects it with alt+#.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #6 on: May 10, 2008, 07:14 PM »
To me it seems like this regex stuff needs little simplification for end user. Also any chance of implementing consistent tab behaviour would be great. I personally prefer tab to move to next argument, and use space for words seperation.

Maybe someone can make simple regex tutotial explanation that is usable for Farr?


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #7 on: May 10, 2008, 07:18 PM »
i think what might be good is a little wizard or helper on that alias editing dialog, that would help walk the user through common scenarios.  advanced users could always customize the regex, but it would at least hold your hand a little if you want to use a simple, typical type of trigger (like you said before a series of space or comma separated arguments, etc).  at least that would handle most common scenarios easily.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #8 on: May 10, 2008, 07:25 PM »
Definetely. Everyday I love Farr more and more. I would like to move to more advanced usages but it takes time. Your suggestion would be great solution for people who have never heard regex.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #9 on: May 11, 2008, 04:41 PM »
Mouser
One thing I need to understand regarding passing argument is that how can I make sure that Farr can distinguish parameters?

For example lets say that I have 2 arguments made of 2+ words each. Lets say that these arguments will be used for sending email.

sendemail.exe [email protected] [email protected] this is title1 this is again title

So if my command line looks like this, how could Farr distinguish between spaces and know that first 2 are email adresses and rest are just one argument. How can I group items in a sense?


mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #10 on: May 11, 2008, 10:02 PM »
it sort of depends how you need to capture the arguments.  Each email needs to get captured as a separate argument, or just as one?

There are probably a lot of ways to do it using regular expressions but one easy way would be if you used some special identifier to mark where the message title was.

for example if you changed the way you type it to:
sendemail [email protected] [email protected] t=this is title1 this is again title

then you could simply grab:
sendmail (.*) t=(.*)

where $$1 is all the emails, and $$2 is the title.

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: How can I enter 2 seperate arguments?
« Reply #11 on: May 11, 2008, 11:10 PM »
Cool, sounds very logical and easy.