mIRC Home    About    Download    Register    News    Help

Print Thread
#109066 25/01/05 05:47 PM
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
hello again,

i'm hoping someone could help me out with shortening this alias a bit :

Code:
alias -l colorcap {
  if (À,Á,Â,Ã,Ä,Å,ß,Ç,Ð,È,É,Ê,Ê,Ë,Ì,Í,Î,Ï,Ñ,Ò,Ó,Ô,Õ,Ö,Ù,Ú,Û,Ü,Ý,¥, $& 
    à,á,â,ã,ä,å,ç,è,é,ê,ë,ì,í,î,ï,ñ,ò,ó,ô,õ,ö,ù,ú,û,ü,ý,ÿ,ø,¹,²,³,×,÷,¢,£,¼,½,¾, $&
    ª,º,°,©,®,¡,¿,¤,§,«,»,¬,±,µ,¶,þ,Þ,Æ,æ,ð,¸,‘,’ isin 1-) {
    var %v = 1, %u
    while $gettok($1,%v,32) != $null {
      %u = %u %ac1 $+ $left($v1,1)) $+ %ac2 $+ $mid($v1,2)
      inc %v
    }
    return %u
  }
  else {
    var %v = 1, %u
    while $gettok($1,%v,32) != $null {
      %u = %u %ac1 $+ $upper($left($v1,1)) $+ %ac2 $+ $mid($v1,2) 
      inc %v
    }
    return %u
  }
}
  


as you can see this charcater string is quite long but, is neccesary to allow the non letter charcters through...
so, can someone help??

thanks in advance

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I don't really understand why you make that distinction between those weird chars and "normal" chars. Doing upper on those weird chars simply returns the same char, so why make a distinction?

Code:
alias colorcap {
  var %a = 1, %b
  while $gettok($1,%a,32) != $null {
    %b = %b $+(%ac1,$upper($left($v1,1)),%ac2,$mid($v1,2))
    inc %a
  }
  return %b
}


or

Code:
alias colorcap {
  tokenize 32 $1
  scon -r var $(%a = %a,) $!+(%ac1,$upper($left( $* ,1)),%ac2,$mid( $* ,2))
  return %a
}

Pick whichever one you think is prettiest :tongue:


Gone.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I think hes ment to be doing something else to it if its one of them, but his script is incomplete, hes comparing them with ISIN 1- instead of ISIN $1-, and the $left($v1,1)) has an extra bracket. (like i should comment on people missaligning brakets haha), maybe he ment to do a different color, i dont know,

PS: I liked the scon one , nice short code, incredibly harder to follow than the first. smile

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Yeah, I'm curious to know, the way his code looks now doesn't really make much sense.

The scon one I added more like an extra treat to show an unconvential way, though it might not be so good to give a person, they can break it easily when doing modifications on "decoration" not realizing they are corrupting the code.

If I wanted to be really picky, then I should put the initial var declaration outside the scon, and also surround %ac1 and %ac2 by spaces, so that those are evaluated before being passed to the scon.

But as with so many aliases, speed simply doesn't matter at all. An alias like that shouldn't take more than 1 second on 1000 iterations, so who's counting laugh

Cya Dave


Edit:

I actually did some benches and these are the results, both aliases 1000 iterations doing $colorcap(this is a test)

While loop alias: Time taken: 297 ms
Scon alias: Time taken: 281 ms
Optimized scon alias:Time taken: 266 ms

On $colorcap(this is a much longer test than the one before)

While loop: Time taken: 640 ms
Optimized scon:Time taken: 578 ms

Last edited by FiberOPtics; 25/01/05 10:20 PM.

Gone.
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I just did some myself, with out and then with an echo of the result, the processing time is so neglable compared to the time needed to display.

Oh I didnt see why you needed to declare the var outside, until I ran it, and by chance i had a global %a (dont ask me what its from?!?!!?) and it tacks it on the front, so yeah I see why it should be there.

Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
FiberOPtics said :

Quote:
I don't really understand why you make that distinction between those weird chars and "normal" chars. Doing upper on those weird chars simply returns the same char, so why make a distinction?


this is why here

and if you look again i'm not doing upper on those characters just in the else statement there seems to be a issue there. the output just didn't come out right.

davec said:

Quote:
I think hes ment to be doing something else to it if its one of them, but his script is incomplete, hes comparing them with ISIN 1- instead of ISIN $1-, and the $left($v1,1)) has an extra bracket. (like i should comment on people missaligning brakets haha), maybe he ment to do a different color, i dont know,


thanks for pointing out those mistakes..... but none the less it works as is.....

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
FiberOPtics said :

Quote:
I don't really understand why you make that distinction between those weird chars and "normal" chars. Doing upper on those weird chars simply returns the same char, so why make a distinction?


this is why here



I couldnt see why in that your doing a seperate action if its any of them characters, just tell us what its ment to do differently if its one of them.

Quote:
thanks for pointing out those mistakes..... but none the less it works as is.....


It might work as it is, but it doesnt work as you think, becuase 1/2 the code can NEVER run

Code:
alias -l colorcap {
  if (À,Á,Â,Ã,Ä,Å,ß,Ç,Ð,È,É,Ê,Ê,Ë,Ì,Í,Î,Ï,Ñ,Ò,Ó,Ô,Õ,Ö,Ù,Ú,Û,Ü,Ý,¥, $& 
    à,á,â,ã,ä,å,ç,è,é,ê,ë,ì,í,î,ï,ñ,ò,ó,ô,õ,ö,ù,ú,û,ü,ý,ÿ,ø,¹,²,³,×,÷,¢,£,¼,½,¾, $&
    ª,º,°,©,®,¡,¿,¤,§,«,»,¬,±,µ,¶,þ,Þ,Æ,æ,ð,¸,‘,’ isin 1-) {

   ^^ thats always going to be FALSE since "1-" dont have any of them in it!

    var %v = 1, %u
    while $gettok($1,%v,32) != $null {
      %u = %u %ac1 $+ $left($v1,1)) $+ %ac2 $+ $mid($v1,2)
      inc %v
    }
    return %u

    ^^ thus all of this is pointless, and also buggy, but as it never gets run you could have anything in here and it well never error as it never runs
    ^^ in fact i would say you could copy this in with my comments and it well still work.

  }
  else {
    var %v = 1, %u
    while $gettok($1,%v,32) != $null {
      %u = %u %ac1 $+ $upper($left($v1,1)) $+ %ac2 $+ $mid($v1,2) 
      inc %v
    }
    return %u
  }
}
  


Again Whats it ment to do if any of them high asc values are incountered, that it isnt ment to do otherwise?

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I still don't see your point, there's no reason so far that you've specified why those weird chars should be treated any differently from "normal" chars.

And your original cannot possibly work because of two reasons:

1. If those weird chars isin 1- can never be true, since 1- doesn't contain any of those weirdchars.
2. You have put regular comma's between those weird chars, which means that whole string of weird chars is considered as a full string. So only if that ENTIRE string is in $1-, only then would it match. I have no idea why you put those comma's, it simply doesn't make sense.

Just tell us what exactly you want! From my point of view, you simply want to make each first character of each word in a sentence upper case, and with a color, the rest of the word in another color.

If that's the case, then the aliases I gave you are perfect, since $upper doesn't "error" on those weird chars, it simply returns them in the same state.

Btw I'm not going to skim through an entire thread to find out why you want that, you'll just gonna have to do the effort to tell us exactly.

Let's just give you an example to show what Dave and me are talking about:

Code:
alias weirdchars {
  var %a = ÀÁÂÃÄÅßÇÐÈÉÊÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ¥àáâãäåçèéêëìíîïñòóôõöùúûüýÿø¹²³×÷¢£¼½¾ªº°©®¡¿¤§«»¬±µ¶þÞÆæ𸑒
  var %b = 1
  while $mid(%a,%b,1) { 
    echo -a %b -> $v1 * $upper($v1)
    inc %b 
  }
}

Now do /weirdchars in your mIRC and take a close look at the original and the $upper. You will find that all of them are the same, not a single unexpected result.

Also try this from the command line:

//if (À isin 1-) { echo -a match } | else { echo -a no match }
//if (ô,õ isin ô õ ôõ) { echo -a match } | else { echo -a no match }

Greets

Last edited by FiberOPtics; 26/01/05 12:05 PM.
Joined: Aug 2004
Posts: 423
C
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
okay,

i'm gonna have to say that the both of you are right!

i've been trying to recreate the situation(s) on my end that caused the output errors, but havn't been successful...

and i've taken out the extra character string since like you guys have been trying to explain to me, cause again like you said it has no bearing... but, it did work for w/e reason, even though it shouldn't have... perhaps i had an error somewhere else in the script that i didn't see and accidentally fixed it going throuh the code .. ??
end result:
it works.. and without the original code posted in this thread...

so, i appologise for turning somes hairs grey with this.. confused

thanks guys grin

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ok,

the important thing is that it's sorted out.

Good luck with the acro replacer.


Gone.

Link Copied to Clipboard