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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Dansig
Newbie


Joined: 06 Jan 2004
Posts: 4
Location: USA

PostPosted: Wed Jan 07, 2004 12:08 am   

trouble with %i
 
Code:

#alias {csa} {
#if (%1) {
  clanTell=""
  #loop 99 {#add clanTell %{%i}
  #add clanTell " "}
  clan 1 tell %i
  } {clan 1 who}


What I'm trying to do is add %[1-99] to clanTell one at a time because of my If statement. Since I put that If statement in, %2-99 have not been appended to the end of the alias. Unless it's a bug, I've got to do it in that code. Can anyone help me?

PS I also don't want to add %(number) to variable clanTell if it is empty.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Wed Jan 07, 2004 4:38 am   
 
Try this:

#if (%1) {#var parameters {%-1}
#var clantell {}
#loop %numwords(@parameters) {#var clantell {%concat(@clantell," ",%word(@parameters,%i))}}} {clan 1 who}

BTW: #add is used to add numbers, and from the way your alias is set up, I assumed the parameters might include non-numbers too.
Also, the command: clan 1 tell %i, in your original alias, is outside the loop, and cannot use %i.
Reply with quote
Dansig
Newbie


Joined: 06 Jan 2004
Posts: 4
Location: USA

PostPosted: Sun Jan 11, 2004 3:01 am   
 
Oh yeah, forgot about concat. Since zMUD treats string, ints, etc. as a general variable, I assumed #add would work to concatenate strings.

Unfortuantely, the answer you supplied doesn't work for this: "csa working! yay". Unless, of course, zMUD wanted to mock me *snicker*.
That way does work for "cas testing 1 2 3 4" though.
Reply with quote
Dansig
Newbie


Joined: 06 Jan 2004
Posts: 4
Location: USA

PostPosted: Sun Jan 11, 2004 3:04 am   
 
Thanks for helping me out :). I'm a pretty good coder when dealing with C/C++, C#, Java, etc.


EDIT: It isn't working because of the puntuation in the first word.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jan 11, 2004 6:41 am   
 
Why do it the hard way?
#AL csa {#IF %numparam() {#VA clantell {%-1}} {clan 1 who}}

ADDED
If the actual purpose is to send a tell:
#AL csa {#IF %numparam() {clan 1 tell %-1} {clan 1 who}}

Or, if you want both a variable and a tell:
#AL csa {#IF %numparam() {#VA clantell {%-1};clan 1 tell %-1} {clan 1 who}}
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jan 11, 2004 9:29 am   
 
Ahh, stupid me, why couldn't I see what he was trying to do.
Reply with quote
Dansig
Newbie


Joined: 06 Jan 2004
Posts: 4
Location: USA

PostPosted: Sun Jan 11, 2004 8:24 pm   
 
Oooh! Thank you, LightBult. That works great. And thanks again, Danlo, for helping me out too :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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