Unset and Replace Something (Variables)

By ProIcons on Nov 25, 2009

Format: /rps

Lets say that we have vars:

%server1 192.168.1.64:27015
%server2 192.168.1.64:27016
%server3 192.168.1.64:27017

and we type the command: /rps 2 server
we will have

%server1 192.168.1.64:27015
%server2 192.168.1.64:27017

It works with all variables,

%asd1 1
%asd2 2
%asd3 3

/rps 3 asd

%asd1 1
%asd2 2

/rps 1 asd

%asd1 2
%asd2 3

etc...

WARNING. If you have
%server1 asd1
%server2 asd2
%server3 asd3
%Server.1 dfa
%server.2 dfaf
%serverafaf 342d

Mirc will be crash...!!!

alias RPS {
  var %i = $1
  while (%i <= $var($+($chr(37),$2,*),0) ) {
    if ($var($+($chr(37),$2,*),$calc( %i + 1 )) != $null) { set % [ $+ [ $2 ] ] [ $+ [ %i ] ] % [ $+ [ $2 ] ] [ $+ [ $calc( %i + 1 ) ] ] } 
    else { unset % [ $+ [ $2 ] ] [ $+ [ %i ] ] }
    inc %i
  }
}

Comments

Sign in to comment.
ProIcons   -  Nov 30, 2009

i mean that the one variable take the others.. if you want, it is an extra snippet. there is not for everyone.. who ever wants... Lets Say tha you have 3 servers and you want to unset the 2 server, and you have a loop to read all the servers, you can use /rps 2 server so the server 3 will take the position of server 2 and server3 will be removed, and the loop will work fine:

Vars:

%server1 asd
%server2 asd2
%server3 asd3
``` var %i = 1 while (%i <= $var(%server*,0) ) { echo -a %server [ $+ [ %i ] ] ;Returns Servers's values inc %i } } ``` Now if you unset %server2 the loop will not echo %server3 ... because it has 2 servers so it will be read %server1 and %server2 , but %server2 does not exists so it will return only %server1 with this alias when you type: /rps 2 server will unset %server2 and %server3 took its place so the alias will be continued normaly ``` %server1 asd %server2 asd3 ``` so now the loop will return: asd asd3
 Respond  
FordLawnmower   -  Nov 29, 2009

That doesn't make much sense ProIcons. Do you have an example of when/why you would use this. I have never had any variables %server1 %server2 etc.

 Respond  
ProIcons   -  Nov 29, 2009

With the command /rps 2 server you unset the variable %server2 and var %server3 took %server2's place, and etc... Example

We Have Variables:
%server1 asd
%server2 asd2
%server3 asd3
%server4 asd4

rps 2 server (%server2)

Now We have variables:

%server1 asd
%server2 asd3
%server3 asd4

 Respond  
Rolo   -  Nov 26, 2009

.... wait wut

 Respond  
FordLawnmower   -  Nov 26, 2009

I'm lost ;/ What do you use this for?

 Respond  
Lord-Harlot   -  Nov 26, 2009

You should make it so it doesn't crash.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.