mIRC Homepage
Posted By: LethPhaos string and replace - 16/03/05 09:14 PM
i've got a string and i need to replace all spaces by _
$replace(%value,$chr(160),_)
doesn't work (seems to me)
Posted By: Mpdreamz Re: string and replace - 16/03/05 09:22 PM
alot of people seem to be using 160 lately. Please use $chr(32)
160 is not a space in all fonts smile
Posted By: LethPhaos Re: string and replace - 16/03/05 09:30 PM
Thanks
Posted By: LethPhaos Re: string and replace - 16/03/05 09:39 PM
if ( !%wzl-trivia_cleaned_ $+ $replace(%value,$chr(32),_) ) {
set %wzl-trivia_cleaned_ $+ $replace(%value,$chr(32),_) 1
echo %wzl-trivia_cleaned_ $+ $replace(%value,$chr(32),_)
}
returns as echo:
gestopt
%value=gestopt
it should return 1 off course
whats wrong???
the var sets itself correctly (%wzl-trivia_cleaned_gestopt 6426)

question clear enough? smirk smile
Posted By: tidy_trax Re: string and replace - 16/03/05 09:42 PM
Code:
if (![color:red]$($+([/color]%[color:red],[/color]wzl-trivia_cleaned_[color:red],[/color]$replace(%value,$chr(32),_)[color:red]),2)[/color]) {
  set %wzl-trivia_cleaned_ $+ $replace(%value,$chr(32),_) 1
  echo [color:red]$($+([/color]%[color:red],[/color]wzl-trivia_cleaned_[color:red],[/color]$replace(%value,$chr(32),_)[color:red]),2)[/color]
}
Posted By: FiberOPtics Re: string and replace - 16/03/05 10:24 PM

var %a = $+(%,wzl-trivia_cleaned_,$replace(%value,$chr(32),_))
if !$(%a,2) { inc $(%a) | echo $(%a,2) }
Posted By: LethPhaos Re: string and replace - 17/03/05 08:16 PM
Thanks a lot!!!, solved the problem with a combination of your answers.
Posted By: SladeKraven Re: string and replace - 17/03/05 09:17 PM
Quote:

alot of people seem to be using 160 lately. Please use $chr(32)
160 is not a space in all fonts


That's because when you type several consecutive spaces into the Scripts Editor, only the first space is recognized; all spaces that follow are ignored.

That's why we use $chr(160) to force blank spaces in our scripts.

In LethPhaos' situation indeed a $chr(32) was needed but this is $chr(32) Vs. $chr(160)

Code:
//echo -a $str($chr(32),6) Hello | echo -a $str($chr(160),6) Hello


Using this will align the second Hello (with $chr(160)) starting the H below the o from the first Hello (without $chr(160))

//echo -a Hello $+ $chr(32) $+ world!

Returns Hello world!

//echo -a Hello $+ $chr(160) $+ world!

Returns Hello world!

//echo -a Hello $+ $str($chr(32),2) $+ world!

Returns Hello world! (but with only one space)

//echo -a Hello $+ $str($chr(160),2) $+ world!

Returns Hello world! (but with 2 spaces)
Posted By: FiberOPtics Re: string and replace - 18/03/05 04:28 AM
He knows that 0160 is a hard space in a lot of fonts, but what you must understand is that 0160 isn't a hard space in all fonts, in a lot it isn't.

Type //echo -a a $chr(160) b

in your status window, and then change your font to Terminal. You'll see what he's referring to.

The point is, if you use $chr(160) in your scripts, and those strings are outputted to a channel fex, it may not appear to everyone as it appears on your font.

Greets
© mIRC Discussion Forums