int asc(string char)
Pass a one character string, returns the ascii value. This is not very fast, so don't overuse it. I've provided a binary version as well now, should be faster. This function is obsolete. Use the builtin Verge3 asc() instead.
int asc(string char)
// Pass: A one character string
// Return: The ascii value of the chr, 0 on fail
// Credit: pelican
{
int c;
int i = 128;
int x = 128;
while (i)
{
c = strcmp(char, chr(x));
if (!c) return x;
i = i>>1;
x += c * i;
}
return 0;
}
int asc(string char)
// Pass: A one character string
// Return: The ascii value of the chr, 0 on fail
// Assmes: Passed string is one character exactly
{
int i;
for (i = 1; i < 256; i++)
{
// To optimise, create an array[256] and sort
// front to back by commonest occurence
if(!strcmp(char, chr(i))) return i;
}
return 0;
}There are no talkbacks on this documentation page yet. Post the first?
Doc Nav |
![]() |
Your docs |
![]() |