mIRC Homepage
Posted By: dragonslayere replacing letters - 11/03/03 03:33 AM
what wrog with this?
it suppose to replace every o with a 0..
i always get
O Unknown command
------------------------------------------------------------------------
on *:INPUT:*:{
if ( o isin $1- ) {
$replace(o,$1-,msg $chan u)
halt
}
Posted By: Collective Re: replacing letters - 11/03/03 03:40 AM
It would be easier to help if you said what you were trying to do...(you said you wanted to replace o with 0, but what do you want to do with the text you get?)

$replace is used like this:
I want to replace the e in the word hello with the letter b, so I use this:
//echo -a $replace(hello,e,b)


Code:
on *:INPUT:*: {
  if ( o isin $1- ) {
    msg $active $replace($1-,o,0)
    halt
  } 
}
^I think that will do what you are trying to.
Posted By: NightChillz Re: replacing letters - 11/03/03 06:10 PM
Yeah, but the way i see it, you will have a problem, unless you are already aware of it....but:

on *:input:*:{
if (o isin $1-) {
msg $chan $replace($1-,o,0)
halt
}
}

will only send the message IF there is an o within the text, otherwize, the message will never get sent...... you dont need an if condition at all in that:

on *:input:*:{
msg $chan $replace($1-,o,0)
}

$replace will be called, and replace only the o's with a 0 , and return everthing else the way it was, and if there are no o's in the text, it will return text exactly, the other way only preformed the /msg IF there was an o in text, dunno if you were 100% aware of this or not, but thought i'd let you know anyway
Posted By: Collective Re: replacing letters - 11/03/03 06:28 PM
You are right that the if statement is not needed, but you are wrong that messages not containing a o will not be sent - the /halt is done only is there is a o in the text, and it is to stop 2 messages being sent (1 message with the replaced text, 1 without) - the /halt will not be done for messages without a so those messages will be sent as normal.

In your script there are 2 problems:
1. All of your messages will be sent twice - once with the "o"s replaced, once without.
2. This code:
on *:input:*:{ msg $chan
Will not work in a query, because $chan will be $null - that is why I used $active.

Both of our scripts have 1 flaw though - /commands are filtered too - they shouldn't be.

Code:
on *:input:*:{
  if ( $left($1,1) != / ) {
    msg $active $replace($1-,o,0)
    halt
  }
}
Posted By: NightChillz Re: replacing letters - 11/03/03 06:36 PM
lol, yeah ur right, wasn't thinkin of /commands at the time, details :P
Posted By: dragonslayere Re: replacing letters - 11/03/03 09:16 PM
on *:input:*:{ if ( $left($1,1) != / ) { msg $active $replace($1-,o,0) halt } }
--------------------------------------------------------------------------

k it replace the leter but it says halt after it and it repeats the text in unreplaced form too


<q[o_O]p> 00 halt
<q[o_O]p> oo
<q[o_O]p> 00 halt
<q[o_O]p> oo
<q[o_O]p> s0 halt
<q[o_O]p> so
<q[o_O]p> Oh
<q[o_O]p> 0 halt
<q[o_O]p> s0s halt
<q[o_O]p> sos
<q[o_O]p> 0s halt
<q[o_O]p> os
<q[o_O]p> asasa halt
<q[o_O]p> asasa
<q[o_O]p> sad halt
<q[o_O]p> sad
Posted By: Collective Re: replacing letters - 11/03/03 09:42 PM
You have to put in the new lines like it shows it on the forums. I.e
Code:
on *:input:*:{
  if ( $left($1,1) != / ) {
    msg $active $replace($1-,o,0)
    halt
  }
}

not
Code:
on *:input:*:{ if ( $left($1,1) != / ) { msg $active $replace($1-,o,0) halt } }
Posted By: dragonslayere Re: replacing letters - 13/03/03 12:02 AM
k it works but now how to i make it so it can can more then one letter?
cause this won't work
--------------------------------------------------------------------------

on *:input:*:{
if ( $left($1,1) != / ) {
msg $active $replace($1-,o,0)
halt
}
if ( $left($1,1) != / ) {
msg $active $replace($1-,w,\/\/)
halt
}
}
-------------------------------------------------------------------------
Posted By: MonoSex Re: replacing letters - 13/03/03 12:15 AM
Code:
on *:input:*:{
  if ($left($1,1) != /) {
  msg $active $replace($1-,o,0,[color:green]w,\/\/[/color],[color:blue]e,3[/color],[color:purple]s,5[/color])
  halt
}
Posted By: dragonslayere Re: replacing letters - 13/03/03 03:13 AM
ok thnx now one more thing how do i how can i replace words just words and not letters?

ex: "i am in pian" should come out "ich bin in pain"(w/e the german word is)

and not "ich bin ichn pichan"

the ich replaces evey "i"

Posted By: NightChillz Re: replacing letters - 13/03/03 05:03 PM
$replace($1-,i am a pain,ich bin in pain)
Posted By: dragonslayere Re: replacing letters - 15/03/03 01:25 AM
$replace($1-,i am a pain,ich bin in pain)
_________________________________________________

i know that i can do that but what i want to know was how i can do an identifer to see if the the word being replace by itself and reither or not to do the replace..

ex: if i type "i am in" it would replace the "i" because its by itself and not the i in "in"
Posted By: Nimue Re: replacing letters - 15/03/03 01:34 AM
Code:
on *:input:*:{
  if (/* iswm $1) || !$ctrlenter { return }
  var %a = $1-
  while $istok(%a,i,32) { %a = $reptok(%a,i,ich,1,32) }
  while $istok(%a,am,32) { %a = $reptok(%a,am,bin,1,32) }
  
  ;and so on ...

  msg $active %a
  halt
}
Posted By: dragonslayere Re: replacing letters - 16/03/03 06:39 PM
doesn't work .....
Posted By: Nimue Re: replacing letters - 19/03/03 12:52 AM
Yep, sorry, replace this line
if (/* iswm $1) || $ctrlenter { return }
© mIRC Discussion Forums