|
Beckyanne Newbie
Joined: 11 Jun 2011 Posts: 4
|
Posted: Sat Jun 11, 2011 5:38 am
Repeating an alias with multiple parameters |
I'm sure this is ridiculously easy . . . once you know how. I've combed help files and searched the forums for an answer, but didn't see one that addressed what I was trying to do. Lots of stuff about using the same parameter for different things, but nothing on how to deal with multiple parameters in an alias.
I'm creating an alias that I would like to repeat the command for each parameter I enter. Specifically, I'm tired of typing "+skim <bb board name>" for every message board in game to list new messages.
I found a very clunky way to do it, but it seems there ought to be a better way.
Code: |
#ALIAS skim {+skim %1;+skim %2;+skim %3}
|
This works, sort of. But sometimes I only need to check one board, sometimes I might need to check 4 or more. So I figured out how to make the alias loop for the number of parameters:
Code: |
#loop %numparam(%-1) {+skim %1}
|
But as you can see, this just repeats it with the first parameter. What do I need to change to make it advance through the parameters I input each time? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Jun 11, 2011 5:54 am |
#FORALL %replace(%params, " ", "|") {+skim %i}
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Beckyanne Newbie
Joined: 11 Jun 2011 Posts: 4
|
Posted: Sat Jun 11, 2011 6:12 am |
Excellent, works like a charm.
Now to break it apart and figure out why it works.
Thank you! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Jun 11, 2011 6:16 am |
%replace(%params, " ", "|")
that simulates a variable list, the expected parameter of the forall command, which loops through each value and assigns it to %i for each iteration of the command parameter |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Beckyanne Newbie
Joined: 11 Jun 2011 Posts: 4
|
Posted: Sat Jun 11, 2011 6:49 am |
I didn't mean you had to explain it, but thank you nonetheless. I'd already went to look up all the components and taught myself, which is better anyways. I was even able to make it return a different value when entered without any parameters at all.
if (%null(%1)) {+bbscan} {#FORALL %replace(%params, " ", "|") {+skim %i}}
Again though, thank you for your help. |
|
|
|
|
|