; $getasc - Roy
; Credits
; -------
; This snippet may appear similar to Lindrian's $asc snippet, part of the snippet actually does what Lindrian's snippet does.
; I give credit to Lindrian for the original idea of the $chr demo.
; -------
; Usage
; -------
; $getasc(string).dem/chrform or nothing at all
; dem returns the string in a (chr) = (chr num) format
; chrform returns the string $chr(chr num) format
; or you can just get the chr values with no property
; -------
; --Roy
; See in-code examples for a better idea on how to use it.
; $getasc - Roy_
; Usage
; -------
; $getasc(string).dem/chrform or nothing at all
; dem returns the string in a (chr) = (chr num) format
; chrform returns the string $chr(chr num) format
; or you can just get the chr values with no property
; -------
; Examples
; -------
; //echo -a $getasc(test) -> 116 101 115 116
; //echo -a $getasc(test).dem -> t = 116 e = 101 s = 115 t = 116
; //echo -a $getasc(test).chrform -> $chr(116) $chr(101) $chr(115) $chr(116)
; -------
alias getasc {
if ($isid) && ($1-) {
if ($prop = dem) {
var %a $1-, %b $len($1-), %c 1
while (%c <= %b) {
var %t = $+(%t,$chr(32),$mid(%a,%c,1),$chr(32),=,$chr(32),$asc($mid(%a,%c,1)))
inc %c
}
return %t
}
if ($prop = chrform) {
var %a $1-, %b $len($1-), %c 1
while (%c <= %b) {
var %t = $+(%t,$chr(32),$,$+(chr,$chr(40),$asc($mid(%a,%c,1)),$chr(41)))
inc %c
}
return %t
}
elseif (!$prop) {
var %a $1-, %b $len($1-), %c 1
while (%c <= %b) {
var %t = $+(%t,$chr(32),$asc($mid(%a,%c,1)))
inc %c
}
return %t
}
}
}