|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
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  Zyzzyx.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
thnx i try that one 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,.) }
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
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.
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Tell me if it works Sigh: using 2- in $gettok is a good idea
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
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 ---> -9About the loop.. you can try something like this:
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  Zyzzy.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
thnx that working with som modifying..  the code works just fine, but it wont echo the way i want it to 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,.) }
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Cool  - Over here it echos like this: #home #foobar #james #officeI don't know how you wanted it to echo, but if it's working, that's good
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
OP
Hoopy frood
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,.) }
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
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
|
|
|
|
|