$chr() List dialog

By alabama on Oct 13, 2011

Screenshots

Saw someone make something similar to this, but this is all the chrs in 1 dialog

Right click any window, nicklist, status window, etc. and click $Chr List
OR
Type /chr

thanks to Dean for revisioned version

dialog chr {
  title "$chr table"
  size -1 -1 66 90
  option dbu
  list 1, 8 12 25 50, size
  list 2, 34 12 25 50, size
  text "", 3, 9 63 50 8
  text "$chr(n)", 4, 9 4 19 8
  text "Symbol", 5, 35 4 20 8
  button "msg active", 6, 13 72 42 12
}

menu nicklist,channel,menubar,status { 
  .$!Chr List:{ dialog $iif($dialog(chr),-v,-m) chr chr } 
}

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 255) { 
    if (%x isnum 33-126) || (%x isnum 160-254) { did -a chr 1 %x | did -a chr 2 $chr(%x) }
    inc %x
  }
}

on *:dialog:chr:sclick:1,2:{
  var %id = $iif($did == 1, 2, 1)
  did -c chr %id $did($did).sel
  did -ar chr 3 $!chr( $+ $did(1).seltext $+ ) = $did(2).seltext
}

on *:dialog:chr:sclick:6:{
  msg $active $did(2).seltext
}

Comments

Sign in to comment.
Wims   -  Nov 03, 2011

this is because mirc is now (since 7.x) an unicode application, internally, $chr(130) get translated to utf8 (the way mirc is representing unicode internally) and as you can guess, in utf8, $chr(130) is represented by two bytes whose value are 194 and 130, regex are handled with a library which work, by default, 'per character':
$regex($chr(130),/./g) is 2 because mirc pass the internal (utf8) value of the character which is in fact two bytes.
To solve the problem, you can tell the regex engine to interpret the input string as utf8 before matching by adding (UTF8) as the first thing to match in the pattern:
$regex($chr(130),/(
UTF8)./g) is 1

alias get_chars return $regsubex($1-,/(*UTF8)(.)/g,$!chr( $+ $asc(\t) $+ ) $!+ $+ $chr(32)) :)

 Respond  
Conscious   -  Nov 03, 2011

That's broken, SReject. Try doing something like //echo -a $get_chars($chr(130)) - returns $chr(194) $+ $chr(130) $+

 Respond  
SReject   -  Nov 02, 2011

Thank you wims, I forgot about needing the (*UTF8) part :)

alias get_chars return $regsubex($1-,/(*UTF8)(.)/g,$!chr( $+ $asc(\t) $+ ) $!+ $+ $chr(32))
 Respond  
FreeHuman   -  Nov 02, 2011

Any Charter Named (H) like ® ?

 Respond  
FreeHuman   -  Nov 02, 2011

Verrrrry Good Script.

 Respond  
napa182   -  Oct 15, 2011

@dm4sfio there are a few Chr talkers posted in the snippet section. Just do a search that is what it is there for....
;x

 Respond  
Jethro   -  Oct 15, 2011

Well, our intelligence can't be measured superficially and compared to one another. We were born with certain intellects. But through the hard work, practice, and persistent learning, we can develop and increase our perception of an object we study. Then we become better and adaptable at following the grammatical rules and improve thereon. I can't speak for jaytea. He's the one allowable to speak for himself if he's superior in MSL then the rest of us. The truth is, he has dedicated many, many years of exposure to MSL and thus he knows how it works inside out.

 Respond  
yelow79   -  Oct 15, 2011

Nah I will never be as good at this as jaytea.

 Respond  
Jethro   -  Oct 15, 2011

Not to you, Dean, but to all of us. Come on man, you can't possibly bring that phrase into question...

 Respond  
_Dean_   -  Oct 15, 2011

One last thing, when someday you're as good as jaytea

this message was directed to...?

 Respond  
Conscious   -  Oct 15, 2011
alias get_chrs {
  var %i 1,%t
  while (%i <= $len($1-)) {
    var %t = $iif(%t,%t $!+) $!chr( $+ $asc($mid($1-,%i,1)) $+ )
    inc %i
  }
  msg $active %t
}

Are you looking for something along the lines of that? (Note: wrong place to ask dm4sfio)

 Respond  
dm4sfio   -  Oct 15, 2011

does anyone have this where you can type in
Hello MIRC
and then send it to active like
$chr(72) $+ $chr(101) $+ $chr(108) $+ $chr(108) $+ $chr(111) $chr(77) $+ $chr(73) $+ $chr(82) $+ $chr(67)
also in reverse decode type in chr & send text to active
ive looked every where no luck if anyone could due this i think alot would apreciate it besides me. thanks

 Respond  
Jethro   -  Oct 15, 2011

One last thing, when someday you're as good as jaytea, you may begin to wonder how I can save those who make "useless scripts and admire them intensely." jaytea is the man on a mission.

 Respond  
Jethro   -  Oct 15, 2011

That looks like something I drew out of boredom when I was in preschool.

 Respond  
Frenetic   -  Oct 15, 2011

For some odd reason, that reminds me of Lady gaga.

 Respond  
alabama   -  Oct 15, 2011

Image

 Respond  
_Dean_   -  Oct 15, 2011

why im feeling that you guys are acting with drama?
i didnt say nothing... i just said that i understood the example... and i didnt mention that he was wrong

 Respond  
blackvenomm666   -  Oct 15, 2011

i concurr with that jethro jaytea has many years of msl under his belt he is a very smart guy and its definately a good idea to listen to what he has to say

 Respond  
Jethro   -  Oct 15, 2011

Dean, no one is hinting the notion of workability and vice versa. jaytea was wheeling people to code with a good habit. I have to admit I make lots of bad habits in MSL. Perhaps I still do, and I'm always on the verge of refining and perfecting myself. Without people like jaytea acting as a mentor, many MSL learners may not have been aware of what they can improve upon. There's no denying that jaytea has many extensive years of MSL experience and skill under his belt.

 Respond  
jaytea   -  Oct 15, 2011

yes i understood guys... but calling something "inefficient" is the same as saying that it wont work correctly

not at all. that would be 'incorrect' or 'dysfunctional'. in fact, saying something is 'inefficient' implies it DOES work correctly since we would just call it broken otherwise ;)

by the way, the FASTEST method would be 189 lines of code resembling 'did -a chr 1 33 | did -a chr 2 !', but that's obviously ridiculous. we need to find a healthy balance between the sensible, the efficient, and the maintainable - and i feel that, in this case, a method involving wasteful iterations tips that balance unfavourably.

 Respond  
  -  Oct 15, 2011

lol didnt see the other post till after posting

 Respond  
_Dean_   -  Oct 15, 2011

yes i understood guys... but calling something "inefficient" is the same as saying that it wont work correctly
when in fact, it work... its just another method, even if you say it will run the loop through 127-159 it will work, and will return the same results correctly

 Respond  
Jethro   -  Oct 15, 2011

And they say old habits die hard...

 Respond  
  -  Oct 15, 2011

Dean, I think he means that its still going through those numbers in the loop
maybe something along the lines of this would be faster donno have not tested to see

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 255) {
     if (%x == 127) { var %x 160 }
     did -a chr 1 %x | did -a chr 2 $chr(%x) 
    inc %x
  }  }
 Respond  
jaytea   -  Oct 15, 2011

it's not a matter of opinion, using 2 while loops is undoubtedly faster. maybe not faster to type, but certainly faster for mIRC to execute. this is because you're cutting down on the amount of work performed in each iteration of those loops, as well as reducing the number of total iterations. if you're still not convinced, try benchmarking 2 minimally functional versions of those methods (/noop instead of /did etc.).

creating inefficient code because it's easier to write is something we should avoid doing ourselves let alone suggesting to people ;P it's simply bad coding practice.

 Respond  
Jethro   -  Oct 15, 2011

Dean, your example is indeed ignoring 127-159, but the loop still travels through it. jaytea was pinpoint that as being unnecessary...though it's a trivial matter really.

 Respond  
_Dean_   -  Oct 15, 2011

jaytea the first post of alabama was like this

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 127) { did -a chr 1 %x | did -a chr 2 $chr(%x) | inc %x }
  var %y = 160
  while (%y < 255) { did -a chr 1 %y | did -a chr 2 $chr(%y) | inc %y }
}

as i mentioned, using !isnum operator would make it shorter and faster in my opinion, but as you said, different methods

on my last example i think it is fine, since its ignoring the characters between 127-159

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 255) {
    if (%x !isnum 127-159) { did -a chr 1 %x | did -a chr 2 $chr(%x) }
    inc %x
  }
}

but thanks for the example, now i understand it

 Respond  
jaytea   -  Oct 15, 2011

'waste of time'? Dean:

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 255) { 
    if (%x !isnum 127-159) { did -a chr 1 %x | did -a chr 2 $chr(%x) }
    inc %x
  }
}

between %x = 127 and %x = 159, the loop does nothing except cycle unnecessarily. THAT is a waste of time, albeit a small one. this is what i meant:

on *:dialog:chr:init:*:{
  var %x = 33
  while (%x < 255) { 
    if (%x == 127) %x = 160
   did -a chr 1 %x | did -a chr 2 $chr(%x)
    inc %x
  }
}

the difference in execution time is so insignificantly small in this case that it really doesn't matter. but it is plain incorrect to say using 2 separate while loops is a 'waste of time' because it actually produces faster code. if you're not able to see this, consider that your method requires mIRC to perform an if statement for all 222 of its iterations, of which 33 are completely redundant.

 Respond  
alabama   -  Oct 14, 2011

what

 Respond  
yelow79   -  Oct 14, 2011

Actually it was Dean

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.