Creating Aliases With Optional Parameters - DonationCoder.com
Welcome Guest.   Make a donation to an author on the site August 28, 2015, 09:48:17 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2015! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Creating Aliases With Optional Parameters  (Read 278 times)
wraith808
Supporting Member
**
Posts: 7,281



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: August 05, 2015, 03:33:00 PM »

So, I've just gotten into creating aliases, and I don't know how I didn't do this before!  But I want to create an alias with optional parameters, and regex is not working for me.

The program (QuickNote for OneNote - note.exe) allows you to feed in the note text, a switch for displaying the note, and a switch for the category.  I want the switch for the category to be optional.

The RegEx

^QuickNote (.*),(.*)?

The commands:

QuickNote - $$1 | C:\Users\charlesl\My Files\Dropbox\Tools\QuickNote\Note.exe $$1 /sect $$2
QuickNote and Display - $$1 | C:\Users\charlesl\My Files\Dropbox\Tools\QuickNote\Note.exe $$1 /disp /sect $$2

It works... but you have to put a , at the end (I tried making the , optional, but that made it match the whole string, instead of splitting it).  I can live with that, even though it's suboptimal.

Is there a way to make it, however, so that if the second param is empty, it uses a default for that second parameter?  Or to check if that second parameter is set, and change behavior based on that?
Logged

mouser
First Author
Administrator
*****
Posts: 34,916



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: August 06, 2015, 12:11:39 AM »

quick response first: perhaps the easiest solution would be to create 2 aliases, one for when you have both parameters and one for if you have only one.
there are probably other solutions using regex, though i dont know off hand of a way to have a default parameter.. it's an interesting idea for a feature to add to the alias system..
Logged
wraith808
Supporting Member
**
Posts: 7,281



"In my dreams, I always do it right."

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: August 06, 2015, 09:03:40 AM »

quick response first: perhaps the easiest solution would be to create 2 aliases, one for when you have both parameters and one for if you have only one.
there are probably other solutions using regex, though i dont know off hand of a way to have a default parameter.. it's an interesting idea for a feature to add to the alias system..

That's what I thought the answer would be after playing with it a bit.  Thanks for the reply.
Logged

Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.026s | Server load: 0.16 ]


Share on Facebook
submit to reddit