Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - asc() convert a character to its ascii code http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 asc()               Convert a character to its ASCII code
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func uint asc extern
   param const char cString

 Arguments
   cString is a character string.

 Return
   ASCII code of the first character of the input string.

 Description
   The asc() function returns the ASCII code value of the first character of
   a string.

   Force regards one-byte long characters delimietd with single quotes
   (e. g. 'x') as byte constants. For a single character to be regarded
   as a string, place it in double quotes.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_asc
   ? asc("F")                    // prints 70
   ? asc("Force")                // prints 70
   ? asc("a")                    // prints 97
   ? asc("z") - asc("a")         // prints 25
   ? asc("")                     // prints 0
   
   /*
   Single quoted, single character strings are considered to be the
   "asc" value of the enclosed character. Using such byte constants is
   faster because the Force compiler uses the ascii value at compile time,
   versus calling the asc() function at runtime.
   */
   ? 'X'                         // prints 88
   ? asc( "X" ) == 'X'           // prints .t.
   endproc

   proc main
   Test_asc()
   endproc

See Also: chr() ival()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson