ASCII evaluator v2

By RagBot on Nov 30, 2009

I needed a simple script that converted multiple CHR and ASCII codes.

Syntax
/char
/ascii

V2 UPDATE**
I didn't want to change without first understanding regex, but now that I do (mostly), I want to make this script a bit more efficient. So I'm changing this to regex format. A thanks to sunslayer for pushing me towards learning regex, even thought it was unintentional.

alias ascii { echo -a 07ASCII: $regsubex($1-,/(.)/g,$+($iif(\n == 1,$+(07,$chr(91),)),$chr(32),$!asc,$chr(40),\t,$chr(41) = $asc(\t) $iif(\n != \0,$+(07,$chr(93),$chr(91),),$+(07,$chr(93),)))) }

alias char { echo -a 07CHR: $regsubex($1-,/(\d+)(?=(?:\W)+|.*)/g,$+($iif(\n == 1,$+(07,$chr(91),)),$chr(32),$!chr,$chr(40),\t,$chr(41) = $chr(\t) $iif(\n != \0,$+(07,$chr(93),$chr(91),),$+(07,$chr(93),)))) }

Comments

Sign in to comment.
Jethro   -  Dec 03, 2009

It's just one way of evaluating ascii characters. Yes, you can walk away from such idea, and you don't have to like it. Others may find it otherwise.

 Respond  
^Neptune   -  Dec 03, 2009

Binvars for this? walks away

 Respond  
Jethro   -  Dec 03, 2009

Didn't you mean "suffered" as the past tense? It was merely a mistake, which we all make mistakes from time to time, right? Don't sweat the small stuff! :P

 Respond  
sunslayer   -  Dec 03, 2009

P.S. I think sunslayer has those two aliases reversedsrry, i suffer from a severe case of dyslexia...

 Respond  
Jethro   -  Dec 02, 2009

Other than regex, you can also use mirc's binary variables to accomplish:

alias char { 
  if (!$1) { echo -a * Enter a number: e.g. /char <numbers> }
  else { bset &b 1 $1- | echo -a $+(CHR,:,$chr(32),$bvar(&b,1-).text) }
}
alias ascii { 
  if (!$1) { echo -a * Enter a character: e.g. /ascii <characters> }
  else { bset &b 1 $1- | echo -a $+(ASCII,:,$chr(32),$bvar(&b,1-).nword) }
}

P.S. I think sunslayer has those two aliases reversed, where the ascii one should be the char one, and vice versa.

-Edited added a check.

 Respond  
RagBot   -  Dec 02, 2009

I fixed Ghost-writer's suggestion, I thought it was a good idea at the moment. As for Sunslayer's regex: I don't know how to use regex, I should learn to soon though.

 Respond  
sunslayer   -  Dec 01, 2009

i beat napa to the napa :O

 Respond  
napa182   -  Dec 01, 2009

WTF IS REGEX!! lmao =P nice one sunslayer

 Respond  
sunslayer   -  Dec 01, 2009

@Testor $addtok will only work if the token doesn't already exist, you can use $instok but using regex is much faster and simpler

alias ascii { echo -a 7CHR: $regsubex($1-,/(.)/g,$+($!chr,$chr(40),\t,$chr(41) = $asc(\t) $iif(\n != \0,$chr(44)))) }
alias char { echo -a 07ASCII: $regsubex($1-,/(\d+)(?=(?:\W)+|.*)/g,$+($!asc,$chr(40),\t,$chr(41) = $chr(\t) $iif(\n != \0,$chr(44)))) }
 Respond  
Testor   -  Dec 01, 2009

^
Also; $Addtok(STring,STringToAdd,Seperator) can be used instead of /set %var %var stringtoadd.

 Respond  
Ghost-writer   -  Dec 01, 2009

if ($1 isnum) { char $1- | halt }

what happens if i wanna know the characte for #1?

 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.