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
godzilla1
Beginner


Joined: 14 Jul 2005
Posts: 22
Location: Budapest

PostPosted: Wed Jul 27, 2005 8:12 am   

variables
 
I have stringlists with numbers.
For example #var joe {1|2|3|4|5}
#var rath {1|2|3|4|5}
etc...
I want to substract every values in every variable with one command. How can i do that?
I tryed to make a new variable like #var names {@joe|@rath...}
#forall @names {#show %i} show all numbers in all variables, but i couldnt change them. Is there any way?
And can i do this (substract all values) if i change the variables to data record?
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jul 27, 2005 8:54 am   
 
Not sure if I understand what you're trying to do.

You want to subtract a number from each value in a stringlist?

So you'd want #var joe {1|2|3|4|5}
to become #var joe {0|1|2|3|4} ?

Something like
#var joe {1|2|3|4|5}
#var temp {}
#forall {@joe} {#additem temp {%eval(%i-1)}}
#var joe {@temp}
Reply with quote
godzilla1
Beginner


Joined: 14 Jul 2005
Posts: 22
Location: Budapest

PostPosted: Wed Jul 27, 2005 9:35 am   
 
Thanks, your answer helped me!
#FORALL @names {
#VARIABLE temp1 {@%%i}
#VARIABLE temp2 {}
#FORALL @temp1 {#IF (%%%i=0) {#VARIABLE temp2 {%additem( 0, @temp2)}} {#VARIABLE temp2 {%additem( %eval( %%%i-1), @temp2)}}}
#VARIABLE %%i @temp2
}

ahol #var names {joe,rath,jim, etc..}
#var joe {1|0|2|1|5|etc..}
and i substract all numbers of all names if they arent equal 0
Reply with quote
godzilla1
Beginner


Joined: 14 Jul 2005
Posts: 22
Location: Budapest

PostPosted: Wed Jul 27, 2005 11:05 am   
 
Another question:
I have an aliase,
one command within the aliase is #forall @names {aliase2 %i}
(@names=joe,etc...)
within aliase2 i want to do :
#var XYZ%1 {ABC} <<<---this should make a XYZJoe named variable with the ABC value, but it doesnt. It makes XYZJoe variable, but the variable is empty. Why?
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Jul 27, 2005 12:34 pm   
 
It should work, and it does for me

#VAR names {joe|bob|jim}
#ALIAS makevars {#forall @names {alias2 %i}}
#ALIAS alias2 {#var XYZ%1 {ABC}}

typing 'makevars' creates XYZjoe, XYZbob, XYZjim, all with value ABC
Reply with quote
godzilla1
Beginner


Joined: 14 Jul 2005
Posts: 22
Location: Budapest

PostPosted: Wed Jul 27, 2005 6:08 pm   
 
Ok, thanks for answer, it really works. My zmud probably was bugged. Just restarted and work.
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