DelphiBasics
Chr
Function
Convert an integer into a character System unit
1 function Chr(IntValue Integer):AnsiChar;
2 function Chr (IntValue Integer:WideChar;
Description
The Chr function converts an IntValue integer into either an AnsiChar or WideChar as appropriate.
Notes
The ansi character set includes control characters such as Chr(27) meaning escape.

Chr(65) gives 'A'

Note that ^A is equivalent to Char(1).
Related commands
CharVariable type holding a single character
OrdProvides the Ordinal value of an integer, character or enum
ValConverts number strings to integer and floating point values
 Download this web site as a Windows program.




 
Example code : Showing Chr and ^ usage
var
  tab  : char;
  crlf : string;
begin
  // Show the use of Chr
  tab := Chr(9);
  crlf := Chr(13)+Chr(10);
  ShowMessage('Hello'+tab+'World');
  ShowMessage('');
  ShowMessage('Hello'+crlf+'World');
  ShowMessage('');

  // Show the equivalent use of ^
  tab := ^I;  // I = 9th capital of the alphabet
  crlf := ^M^J;  // M = 13th, J = 10th letters
  ShowMessage('Hello'+tab+'World');
  ShowMessage('');
  ShowMessage('Hello'+crlf+'World');
end;
Show full unit code
  Hello World
  
  Hello
  World
  
  Hello World
  
  Hello
  World
  
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page