mIRC Home    About    Download    Register    News    Help

Print Thread
#94942 20/08/04 08:33 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
how can i strip a %variable for just 1 part of it?

%tmpchan#channel

i want to strip out #channel ..
then echo that part to me..
but the channel are diffrent every time..
anyone that know a simple way ?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94943 20/08/04 09:05 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Do you mean you want to return a part of the variable's name? Or did I misunderstand the question?


"All we are saying is give peace a chance" -- John Lennon
#94944 20/08/04 09:10 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I want to return #channel <<-- the %variable should be removed..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94945 20/08/04 09:25 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Hmm.. if you know the variable's name, you can use:
Eg.: %var#channel is the variable's name.

$right($eval(%var#channel,0),-4) - and this will return #channel.

If you dont know its name (thus, its length), you can use $gettok:

$gettok($eval(%var#channel,0),2,35) - and this will return the 2nd token on the variable's name, which is #channel (without the #, keep that in mind).

I hope I was able to understand smile
Zyzzyx.


"All we are saying is give peace a chance" -- John Lennon
#94946 20/08/04 09:26 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
thnx i try that one laugh

Nope

echo -a $gettok($eval(%variable,0),2,35)

returns: * /echo: insufficient parameters (line 20, script.ini)

and if i let #channel be there it returns only that one, not the
channel set as %variable :tongue:

Last edited by sparta; 20/08/04 09:31 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94947 20/08/04 09:26 PM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
You can use $var(%tmpchan#*,N) to return the name of the Nth variable matching the wildmatch %tmpchan#* and consequently return the channel using $gettok:

$chr(35) $+ $gettok($var(%tmpchan#*,N),2-,35)

Edit: missed your replies, though you might want to use 2- within the $gettok as I've shown in case # exists inside the channel name

Last edited by Sigh; 20/08/04 09:28 PM.
#94948 20/08/04 09:31 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Tell me if it works smile

Sigh: using 2- in $gettok is a good idea smile


"All we are saying is give peace a chance" -- John Lennon
#94949 20/08/04 09:36 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Sigh:


%var#testing
%var#testing2

and if i use your code it only reply the first channel..
and if i trying to loop it, then it still only return the first channel to me.. not the seccond one.. :tongue: and i maybe have 10 channels set as %var#channel .. :tongue:


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94950 20/08/04 10:47 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
$right($eval(%var#channel,0),-4)
With the code above I can return the channel in the variable. The -4 must be changed to the number of characters in the variable that are *not* the #channel name.
Eg:
%var#channel --> -4
%variable#channel ---> -9

About the loop.. you can try something like this:
Code:
alias [color:green]varchans[/color] {
 var %i = $var([color:orange]%var[/color]*,0)
 while (%i) {
   [color:blue]echo -s [/color]$right($var([color:orange]%var[/color]*,%i),[color:purple]-4[/color])
   dec %i
 }
}
On the code above you can change:
- the alias name (I couldn't come up with a more interesting name :P);
- the variable name - without the #channel name (= the part you want to omit);
- the command you wish to perform:
- the -4 should be replaced with the number of "omission" (see the explanation on the top of the post)

Remember that the variable's name must be the same in order of that loop to work. Meaning you should have this in your variables list:
Eg:
%var#home
%var#foobar
%var#james
%var#office

I tested here and it works as it should. Hope this helps smile

Zyzzy.


"All we are saying is give peace a chance" -- John Lennon
#94951 20/08/04 11:00 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
thnx that working with som modifying.. grin the code works just fine, but it wont echo the way i want it to wink

1 last question about this, how can i get my own stat on the channel ??

if ($me isop $right($var(%var*,%i),-4))

returns a error.. but it should be able to read that. if i am on the channel and im oped, then it should return that ?

Last edited by sparta; 20/08/04 11:31 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94952 20/08/04 11:04 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
Cool smile - Over here it echos like this:

#home
#foobar
#james
#office


I don't know how you wanted it to echo, but if it's working, that's good laugh


"All we are saying is give peace a chance" -- John Lennon
#94953 21/08/04 08:47 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
ne1 that have any idea about the last part ?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#94954 21/08/04 03:46 PM
Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
The if ($me isop $right($var(%var*,%i),-4)) works fine here, using v6.16


"All we are saying is give peace a chance" -- John Lennon

Link Copied to Clipboard