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 - toupper() return character code in upper case http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 toupper()           Return character code in upper case
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func uint toupper extern
   param value uint uASCII

 Arguments
   uASCII is the character code to convert to upper case.

 Return
   The ASCII code of the upper case character.

 Description
   The toupper() function returns the upper case equivalent of the passed
   character code. Extended characters, including German "Umlauts" are
   treated correctly.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   func char MyLower1
   param const char cString
   // A variant of the lower() function that uses the toupper() function
   // to replace string bytes
   vardef
      byte aContents[ 255 ] based cString
      uint n
   enddef
   n := 0
   do while aContents[ n ] > 0
      aContents[ n ] := toupper( aContents[ n ] )
      n++
   enddo
   return( cString )
   endfunc
   
   func char MyLower2
   param const char cString
   // A variant of the lower() function that ustilizes pointers and does
   // not call the toupper() function
   vardef
      ptr( byte ) pContents
   enddef
   pContents := &cString
   do while *pContents
      if *pContents >= 'a' .and. *pContents <= 'z'
         *pContents -= 'a' - 'A'
      endif
      pContents++
   enddo
   return( cString )
   endfunc
   
   proc Test_toupper
   ? chr( toupper( 'A' ) )
   ? chr( toupper( '1' ) )
   ? chr( toupper( 'z' ) )
   ?
   ? MyLower1( "Brigitte Bardot" )
   ? MyLower2( "Marilyn Monroe" )
   endproc

   proc main
   Test_toupper()
   endproc

See Also: tolower()

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