Re: TIB: Converting characters to a numeric (ASCII) value.


[Prev][Next][Index][Thread]

Re: TIB: Converting characters to a numeric (ASCII) value.




In a message dated 11/16/98 7:58:49 PM Central Standard Time,
greg.miller@usa.net writes:

> 	Is there any way to convert a character to a numerical value,
>  and then back again.  I'm not talking about converting "13" to 13, but
>  rather converting the character "A" to 65, then being able to convert
>  65 back to "A".
>  	If the TI doesn't use ASCII, that's fine, I just need to be
>  able to manipulate characters with arithmetic operations, then convert
>  them back to characters.
>  	Right now, I have a big long string of all the characters and
>  a subroutine which scans through them all and returns an index into
>  the string.  So anything better than that would be helpful.
>  
>  	I'm using a TI-86

There's no standard way to do this, but I thought a bit and this is the best
that I could come up with.  You can't convert a char to an int directly, but
this is almost as fast.  (by the way, the calcs do not use ascii or anything
close to it) Anyway, here's how to convert.  Assign all the chars from A to Z
(or theta) to a string in alphabetical order.  When you want to convert
anything, use the position in your alphabet string (probably best to call it
ALPHA) (to find the pos of a char just use a for loop; there's no faster way)
as the number and then do your operations.  When finished, you can use the
sub( command to return the character you want.  This is the fastest and
smallest way I can think of; if anyone can improve it let me know.  Also if
you want some actual code just tell me and I'll see what I can do.
Paul J Chase II