Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Beckyanne
Newbie


Joined: 11 Jun 2011
Posts: 4

PostPosted: 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?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sat Jun 11, 2011 5:54 am   
 
#FORALL %replace(%params, " ", "|") {+skim %i}
_________________
Discord: Shalimarwildcat
Reply with quote
Beckyanne
Newbie


Joined: 11 Jun 2011
Posts: 4

PostPosted: 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!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Beckyanne
Newbie


Joined: 11 Jun 2011
Posts: 4

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net