mIRC Homepage
Posted By: doglem Spacing - 26/06/03 08:33 AM
i know there's probably a post on here already to cover this but i didnt find it, or atleast i dont think i did.

I was working on a MOTD viewer and i am having a hard time keeping the spacing in the lines. I have tried almost everything. I've tried to replace spaces with another $chr(), then whenever i read it from the hashtable replace the $chr() with $chr(32) and and that didnt work, so i tried replacing it with $chr(160) also, and that still didnt work anyone got any ideas?

raw 372:*:{
inc %motdhash
hadd motd %motdhash $replace($replace($2-,$chr(32),$chr(200)),$chr(160),$chr(200))
halt
}

raw 376:*:{
while (%motdhash >= 1) {
did -a motd 2 $replace($hget(motd,%motdhash).data,$chr(200),$chr(32))
dec %motdhash
}
halt
}
Posted By: KingTomato Re: Spacing - 26/06/03 08:55 AM
Yea, let mirc echo it on screen, not you.. thats the only way >:\
Posted By: doglem Re: Spacing - 26/06/03 09:42 AM
what do you mean let mirc echo it on screen not me?
Posted By: KingTomato Re: Spacing - 26/06/03 10:33 AM
I mean don't try to enterpret it with a raw. Any way you try to handle the MOTD with raws, will mess up spacing.
Posted By: qwerty Re: Spacing - 26/06/03 10:49 AM
$1-, in ALL irc events, strips consecutive spaces, so if the server message is this:
a<sp><sp><sp>b<sp>c
$1- contains this:
a<sp>b<sp>c

Obviously, no workaround (like replacing spaces with another character) is possible because $1- doesn't have all the information to begin with.
Posted By: doglem Re: Spacing - 26/06/03 11:06 AM
so theres absolutely no way that i can do what im trying correct?
Posted By: KingTomato Re: Spacing - 26/06/03 11:06 AM
correct.
Posted By: DrkShadow Re: Spacing - 27/06/03 03:18 AM
Contrary to being no way, there is a very, very ugly way to do it. I'm pretty sure. I thought of it long ago, forgot it, wondered what it was because I wanted to make it work, remembered, remembered how ugly and the instances in which it works... *sigh*

It's ugly.

Anyway, in script, $len will return the length of a range of characters. It will even include multiple spaces. so, if you had $1 == ugly, $2 == ugly, $3 == method, with THREE spaces between each parameter, $len($1-2) would be equal to 11. Yes, 11. There's 4 chars in ugly, 3 spaces, and 4 ugly.

Using this method, you could then:
Code:
 
var %paramlen = $len($ [ $+ [ %counter ] ] [ $+ - ] [ $+ [ %counter + 1] ])
if (%paramlen &gt; $calc($len($1) + $len($2) + 1)) {
  echo $1$+ $str($chr(32) $+ $chr(3) $+ $2
} 


.. I think that's right. %counter loops through all the parameters. So, I believe the effect of the len combination is basically: $len($1-2), $len($2-3), etc. until complete (I'm bad with how mirc handles combinations of values to create variable names -- but I believe the method I used here works). The if statement compares to see if there's greater than one space. If it is, create a space + color character combo, in order to get what seems to be multiple spaces. It'll be for the space equal to what was originally there.

Gotcha's:
This'll only work on parameters. You can't go $len(word<space><space>word) or it'll only give you one space. This also won't work for sending text over the link to others. Well, it will, but your max message length will be cut down by one for every space you have (.. pretty much), and most will lynch you for giving them such uglyness.

Also note that I just thought of this one day, I believe when I saw $len give an odd length on some input event, and have NOT tried this. Use at your own risk, and note that you may be wasting your time.

-DrkShadow
Posted By: starbucks_mafia Re: Spacing - 27/06/03 12:55 PM
I've never been able to produce that effect. Most likely control codes were the cause of the apparent $len() irregularities.
Posted By: doglem Re: Spacing - 27/06/03 05:51 PM
yeah, i even tried that before iposted and i got "ugly(doublespace)ugly" to only return 9 that's 4 chars in ugly one space and four more chars in the second ugly"
but thanks anyways
© mIRC Discussion Forums