mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Strip a word #130066
12/09/05 08:25 PM
12/09/05 08:25 PM
Joined: Mar 2005
Posts: 21
I
Iljan Offline OP
Ameglian cow
Iljan  Offline OP
Ameglian cow
I

Joined: Mar 2005
Posts: 21
I have some problems, i have made a scripts that posts in to a db by a php page but the variable of the channel (#dutch in this case) wont be posted in to the db. frown

The problem is the # in the channelname. mad

How do i strip $chan from #dutch to just "dutch" and set it as %temp.channel ?

Re: Strip a word #130067
12/09/05 08:37 PM
12/09/05 08:37 PM
Joined: Dec 2002
Posts: 1,245
California, doooood
M
MikeChat Offline
Hoopy frood
MikeChat  Offline
Hoopy frood
M

Joined: Dec 2002
Posts: 1,245
California, doooood
$remove(#channelname,$chr(35))

Re: Strip a word #130068
12/09/05 08:38 PM
12/09/05 08:38 PM
Joined: Dec 2002
Posts: 3,547
Kent, England
S
SladeKraven Offline
Hoopy frood
SladeKraven  Offline
Hoopy frood
S

Joined: Dec 2002
Posts: 3,547
Kent, England
Hi.

//set %temp.channel $gettok($chan,1,35)
//set %temp.channel $remove($chan,$chr(35))
//set %temp.channel $mid($chan,2-,$len($chan))
//tokenize 35 $chan | set %temp.channel $1

There's four examples of how you can do this. smile

Edit: Changed #dutch to $chan.

-Andy

Re: Strip a word #130069
12/09/05 08:39 PM
12/09/05 08:39 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
set %temp.channel $remove($chan,$chr(35))

or

set %temp.channel $right($chan,-1)

EDIT: Sheesh. Can't even reply within 15 minutes without being beat to it by not one, but TWO people. laugh

Last edited by Riamus2; 12/09/05 08:41 PM.

Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130070
12/09/05 09:03 PM
12/09/05 09:03 PM
Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
FiberOPtics Offline
Hoopy frood
FiberOPtics  Offline
Hoopy frood

Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
Channel names can have multiple #'s in it, so using $remove would remove them all.

$mid($chan,2) is all one really needs, which does the same as your solution with $right.

Then again, maybe he didn't know that channel names can contain multiple #'s, and wants them all removed, which would mean the only good solution is, as you first suggested, $remove.


Gone.
Re: Strip a word #130071
12/09/05 09:49 PM
12/09/05 09:49 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
Yeah, I thought about channels having multiple #'s. smile

I didn't realize the length parameter was optional on $mid. Good to know. smile


Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130072
12/09/05 09:53 PM
12/09/05 09:53 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
hixxy  Offline
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
Or simply replace it with a character that's illegal in a channel name, for example: $replace($chan,$(#,),$chr(44))

Re: Strip a word #130073
12/09/05 09:57 PM
12/09/05 09:57 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
Why?


Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130074
12/09/05 10:03 PM
12/09/05 10:03 PM
Joined: Dec 2002
Posts: 3,547
Kent, England
S
SladeKraven Offline
Hoopy frood
SladeKraven  Offline
Hoopy frood
S

Joined: Dec 2002
Posts: 3,547
Kent, England
Well $chr(44) would not be a very good example to use but as you'd get: ,mIRC but..

$replace($chan,$(#,),$+($chr(32))) would be fine.
$replace($chan,$(#,),$+($chr(3))) would also be fine if characters after the '#' are not numeric.

-Andy

Re: Strip a word #130075
12/09/05 10:04 PM
12/09/05 10:04 PM
Joined: Mar 2005
Posts: 21
I
Iljan Offline OP
Ameglian cow
Iljan  Offline OP
Ameglian cow
I

Joined: Mar 2005
Posts: 21
Thankyou all for helping me out here, i used

set %temp.channel $gettok($chan,1,35)

And it works fine. Keep up the good work!!! smile

Re: Strip a word #130076
12/09/05 10:05 PM
12/09/05 10:05 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
hixxy  Offline
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
So you can retrieve the correct channel name back later, for example:

My method:

Post: (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l# -> (DB) ,w,e,i,r,d,c,h,a,n,n,e,l,
Retrieve: (DB) ,w,e,i,r,d,c,h,a,n,n,e,l, -> (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l#

Your method:

Post: (mIRC) #w#e#i#r#d#c#h#a#n#n#e#l# -> (DB) weirdchannel
Retrieve: (DB) weirdchannel -> (mIRC) weirdchannel

Re: Strip a word #130077
12/09/05 10:06 PM
12/09/05 10:06 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
That was why there was the second method posted. laugh


Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130078
12/09/05 10:08 PM
12/09/05 10:08 PM
Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
FiberOPtics Offline
Hoopy frood
FiberOPtics  Offline
Hoopy frood

Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
Replacing the #'s with a space will not be fine, since I've specifically stated that channel names can have multiple #'s in them.

It would turn the channel #andy#is#crazy to andy is crazy , which is no longer distinguishable as a channel from regular other text.


Gone.
Re: Strip a word #130079
12/09/05 10:11 PM
12/09/05 10:11 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
Hey, you might want to edit that to:

set %temp.channel $gettok($chan,1-,35)

Otherwise, you won't get the entire channel name if it has other #'s in it.

EDIT: Actually, that won't help either as it will remove the #'s.

You should use either of these instead:

set %temp.channel $mid($chan,2)
set %temp.channel $right($chan,-1)

Last edited by Riamus2; 12/09/05 10:19 PM.

Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130080
12/09/05 10:12 PM
12/09/05 10:12 PM
Joined: Dec 2002
Posts: 3,547
Kent, England
S
SladeKraven Offline
Hoopy frood
SladeKraven  Offline
Hoopy frood
S

Joined: Dec 2002
Posts: 3,547
Kent, England
Well I guess so but I'd never attempt to join a channel with consecutive #'s in it, but if others actually do do it well then it was indeed wrong of me. smile

-Andy

Re: Strip a word #130081
12/09/05 10:14 PM
12/09/05 10:14 PM
Joined: Mar 2005
Posts: 21
I
Iljan Offline OP
Ameglian cow
Iljan  Offline OP
Ameglian cow
I

Joined: Mar 2005
Posts: 21
i used it in the following script:

on 1:join:#:{
if ($nick == $me) {
set %temp.channel $gettok($chan,1,35)
.sockopen devesteservjoin some.server.url 80
.timer12 1 2 .sockwrite -n devesteservjoin GET /beheer/update.php?action=join $+ &nick= $+ $me $+ &channel= $+ %temp.channel HTTP/1.0 $+ $crlf
.timer13 1 2 .sockwrite -n devesteservjoin Accept: */* $+ $crlf
.timer14 1 2 .sockwrite -n devesteservjoin User-Agent: mIRC $+ $crlf
.timer15 1 2 .sockwrite -n devesteservjoin Host: some.server.url $+ $crlf
.timer16 1 2 .sockwrite -n devesteservjoin $crlf
echo 4 -s Updating to server | set %chan.join $chan
}
}
on *:SOCKCLOSE:devesteservjoin:{ /echo 4 -s Http server updated, thank you - Join at %chan.join }

Re: Strip a word #130082
12/09/05 10:18 PM
12/09/05 10:18 PM
Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
FiberOPtics Offline
Hoopy frood
FiberOPtics  Offline
Hoopy frood

Joined: Feb 2004
Posts: 2,019
Leuven, Belgium
Hmm, why are you using timers to sockwrite to the connection? They serve no purpose as far as I can tell. Btw you don't need to put a $crlf after each header entry, since you are using the 'n' switch from sockwrite, which will append a $crlf already. Anyway, you've been helped accordingly, so I suppose this thread is finished.


Gone.
Re: Strip a word #130083
12/09/05 10:21 PM
12/09/05 10:21 PM
Joined: Oct 2004
Posts: 8,327
MA, USA
Riamus2 Offline
Hoopy frood
Riamus2  Offline
Hoopy frood

Joined: Oct 2004
Posts: 8,327
MA, USA
Iljan, read me last post (and the edit).

If you try using a channel like #test#1, it won't work correctly as you have it right now. Granted, those types of channel names are few and far between, but better to be safe than sorry.


Invision Support
#Invision on irc.irchighway.net
Re: Strip a word #130084
12/09/05 10:23 PM
12/09/05 10:23 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
hixxy  Offline
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
All he said was that the # in the channel name was the problem, he didn't say it was only a problem if it was at the start of the text so using $right(#channel,-1) could still mess up for things like #channel#.

Re: Strip a word #130085
12/09/05 10:27 PM
12/09/05 10:27 PM
Joined: Dec 2002
Posts: 3,547
Kent, England
S
SladeKraven Offline
Hoopy frood
SladeKraven  Offline
Hoopy frood
S

Joined: Dec 2002
Posts: 3,547
Kent, England
You might want to add those sockwrite commands inside an IF statement to check if the socket is opened otherwise you'll get an error.

Code:
On me:*:Join:#: {
  set %temp.channel $gettok($chan,1-,35)
  .sockopen devesteservjoin some.server.url 80
}

on 1:Sockopen:devesteservjoin:{
  if ($sock(devesteservjoin)) {
    .sockwrite -n $v1 GET /beheer/update.php?action=join $+ &nick= $+ $me $+ &channel= $+ %temp.channel HTTP/1.0 $+ $crlf
    .sockwrite -n $v1 Accept: */* $+ $crlf
    .sockwrite -n $v1 User-Agent: mIRC $+ $crlf
    .sockwrite -n $v1 Host: some.server.url $+ $crlf
    .sockwrite -n $v1 $crlf
    echo 4 -s Updating to server | set %chan.join $chan  
  }
}


-Andy

Page 1 of 2 1 2