mIRC Home    About    Download    Register    News    Help

Print Thread
#272815 19/07/24 09:24 PM
Joined: Dec 2022
Posts: 15
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2022
Posts: 15
I'm trying something very simple:
Code
//echo $replace( ":)" , ":)" , "1,8:)" )

Unfortunately, it gives an error: * Invalid parameters: $replace

What am I doing wrong?

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Comma are used to separate argument, so the comma for the background color is creating another parameter


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Dec 2002
Posts: 5,486
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,486
In addition to Wims comment: for historical reasons, the scripting language does not have "" quote support for strings. This means that quotes are treated as a literal part of the string in most cases. This also means that the ( ) , cannot be used directly as these are part of the $identifier(a,b,c) format. You would need to escape these characters:

Code
//echo $replace( $+(":,$chr(41),") , $+(":,$chr(41),") , $+("1,$chr(44),8:,$chr(41),") )

Or without the quotes, which I assume is what you wanted:

Code
//echo $replace( $+(:,$chr(41)) , $+(:,$chr(41)) , $+(1,$chr(44),8:,$chr(41),) )

Or put them in variables:

Code
var %a = ":)"
var %b = ":)"
var %c = "1,8:)"
//echo $replace( %a , %b , %c )

and without the quotes:

Code
var %a = :)
var %b = :)
var %c = 1,8:)
//echo $replace( %a , %b , %c )

Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Ah yes, the literal () are the real reason for this error.

Note1: if your literal () are balanced inside identifiers, there's no error: $replace((),(),a) returns 'a' correctly.
Note2: By parsing literal () inside identifiers, mIRC stops evaluating until the () are balanced again, $+((,$os,),$os) returns "(,$os,)10"


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard