|
Joined: Dec 2022
Posts: 15
Pikka bird
|
OP
Pikka bird
Joined: Dec 2022
Posts: 15 |
I'm trying something very simple: //echo $replace( ":)" , ":)" , "1,8:)" ) Unfortunately, it gives an error: * Invalid parameters: $replace What am I doing wrong?
|
|
|
|
Joined: Jul 2006
Posts: 4,187
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,187 |
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,493
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 5,493 |
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: //echo $replace( $+(":,$chr(41),") , $+(":,$chr(41),") , $+("1,$chr(44),8:,$chr(41),") ) Or without the quotes, which I assume is what you wanted: //echo $replace( $+(:,$chr(41)) , $+(:,$chr(41)) , $+(1,$chr(44),8:,$chr(41),) ) Or put them in variables: var %a = ":)"
var %b = ":)"
var %c = "1,8:)"
//echo $replace( %a , %b , %c )
and without the quotes: var %a = :)
var %b = :)
var %c = 1,8:)
//echo $replace( %a , %b , %c )
|
|
|
|
Joined: Jul 2006
Posts: 4,187
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,187 |
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
|
|
|
|
|