mIRC Home    About    Download    Register    News    Help

Print Thread
#32265 26/06/03 08:33 AM
Joined: Mar 2003
Posts: 27
doglem Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Mar 2003
Posts: 27
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
}


Mess with the best, Die like the rest.
#32266 26/06/03 08:55 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Yea, let mirc echo it on screen, not you.. thats the only way >:\


-KingTomato
#32267 26/06/03 09:42 AM
Joined: Mar 2003
Posts: 27
doglem Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Mar 2003
Posts: 27
what do you mean let mirc echo it on screen not me?


Mess with the best, Die like the rest.
#32268 26/06/03 10:33 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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.


-KingTomato
#32269 26/06/03 10:49 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#32270 26/06/03 11:06 AM
Joined: Mar 2003
Posts: 27
doglem Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Mar 2003
Posts: 27
so theres absolutely no way that i can do what im trying correct?


Mess with the best, Die like the rest.
#32271 26/06/03 11:06 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
correct.


-KingTomato
#32272 27/06/03 03:18 AM
Joined: Jun 2003
Posts: 3
D
Self-satisified door
Offline
Self-satisified door
D
Joined: Jun 2003
Posts: 3
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

#32273 27/06/03 12:55 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
I've never been able to produce that effect. Most likely control codes were the cause of the apparent $len() irregularities.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#32274 27/06/03 05:51 PM
Joined: Mar 2003
Posts: 27
doglem Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Mar 2003
Posts: 27
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


Mess with the best, Die like the rest.

Link Copied to Clipboard