From: George De Bruin
On Thursday, May 08, 1997 1:40 PM, Frederick Holmes
[SMTP:fsholmes@cpcug.org] wrote:
> function in {COMMO}'s COMMO.MAC where I need to get x or n (the
> number of times to find a comma on the line -- val(times) in
> the macro) as a translation of A=1, B=2, C=3, . . . That's
This is easy to calculate. ASCII is just an ordered sequence of letters
which have numeric codes that are equivalent to the letters. (That's
probably clear as mud!) Example: look at the ASCII chart:
DEC HEX CHAR
65 41 A
66 42 B
67 43 C
68 44 D
And so forth, all the way through the alphabet. This makes it asy to find
the value that you want by doing the following: take the ASCII value of the
uppercase version of the character, subtracting 65 (the base value, in
decimal), then adding one. (Since the 65 and the one will always be
combine, we can just subtract 64). The following proc will return the
integer value of the first character given a string input:
integer proc AlphaNum(string c)
string x[1] = upper(c[1])
if asc(x) >= 65 and asc(x) <= 90
return( asc(x) - 64 )
endif
return(FALSE)
end
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)
|