Getting ASCII value from a character

David Carter-Tod wccartd at wcc.vccs.edu
Tue Nov 26 11:47:53 PST 2002


At 11:33 AM 11/26/2002 -0800, Jeff Shepherd wrote:
>How can I get an ASCII value from a character? An example from another 
>language would be ASCII("A") = 65.  Frontier does the reverse with 
>char(65) = 'A'. I would think this function would be in the coercion 
>verbs, but must have overlooked something.

number(char("A"))

>And in a similar vein, which is the fastest for going though a string?

check out script.startProfile and script.stopprofile (see below).

>text = "This is a string"
>for i=1 to sizeOf(text)
>         text[i]
>         string.nthChar(text, i)
>         string.mid(text, i, 1)
>
>Perhaps one of the string verbs would be slower but might be safer in case 
>of addressing beyond the end of the string. True?

on testScript () {
         script.startprofile(true);
         text = string.filledstring("something somewhere",1000);
         for i=1 to sizeOf(text) {
                 text[i];
                 «string.nthChar(text, i)
                 };«string.mid(text, i, 1);
         script.stopprofile(@scratchpad.profiletest);
         edit(@scratchpad.profiletest)};
testScript()

David
--
David Carter-Tod
<wccartd at wcc.vccs.edu>

Instructional Technologist/Distance Education Contact
Wytheville Community College, 1000 E. Main St.,
Wytheville, VA 24382
(wk) 276-223-4784
http://www.wcc.vccs.edu/




More information about the Frontier-Users mailing list