mIRC Homepage
Posted By: beer Help with (simple) text substitution please! - 01/03/17 05:35 PM
Hi. I've tried looking up examples but haven't managed to figure this out:

I like incoming channel text that looks like this:
[12:57:00] <converter> ( USD ) ( CAD ) +0.31%

to instead look like this:
[12:57:00] <converter> [USD] [CAD] +0.31%

So basically I want to replace "( " with "[" and " )" with "]" on all text in that channel and nothing else. I assume it's done using `on ^*:text:*:#currency:{ ...something here... }`, but I can't figure out how/what.

Many thanks for your help!
$replace($1-2,$chr(40) $+ $chr(32),[,$chr(32) $+ $chr(41),])

Sorry it's a visually ugly/confusing solution. Characters ( and ) and space sometimes need to be escaped with the $chr() command in order to be used in scripts. Indeed, [ and ] sometimes need to be escaped as [[ and ]], but not in this specific case.

I will leave the rest of the script up to you, as you're dealing with Halting Default Text to replace with your own text, which quickly spirals out of control. See the help file for suggestions. If you're going to "prettyify" or alter what somebody else says, there are a million things you'll need to account for when substituting their text: Nickname prefix, Nick Colors, Highlight Colors, all the /echo flags for message/flashing/timestamp, $strip, etc, and any other preferences that affect message output appearances.
Thank you for your help Raccoon! The script I tried is:

Code:
on ^*:text:*:#zzzz:{
  if ($nick == mrc-test) {
    echo -t $chan $+(<,$nick,>) $replace($1-,$chr(40) $+ $chr(32),[,$chr(32) $+ $chr(41),])
    haltdef
  }
}


I created 2 connections to a server and joined test channel #zzzz with "mrc-test" and "beer". From mrc-test I wrote:
"abc ( TEST ) def"

In beer's window I saw:
"[16:28:45] <mrc-test> abc [TEST] def"

And in beer's server window I saw:
"[16:28:46] #ZZZZ Unknown command"

Using "$replace($1-2," wasn't working so I tried changing it to "$replace($1-," and that fixed it. But, I have no clue why the "#ZZZZ Unknown command" is happening. Any ideas?
I can't imagine where the error came from. It might be another script that's responsible. Sorry I gave you the wrong information with $1-2, that was silly of me.
I copy&paste'ed the code block, then deleted the original and now that `Unknown command` message is gone. Maybe some typo that got lost in the c&p? Weird but I'll take it! smile

Thanks again for your help Raccoon!
© mIRC Discussion Forums