testcharliterals.out

来自「格式化源码的最新板」· OUT 代码 · 共 120 行

OUT
120
字号
unit testcharliterals;

interface

implementation

uses Dialogs;

procedure chars;
const
  fred      = #80;
  linebreak = #13#10;
  somechars = #78#79#80;
  hexchars  = #$12#$2E#60;
  dqs_0     = '';
  dqs_1     = '''';
  dqs_2     = '''''';
  dqs_3     = '''''''';
  dqs_4     = '''''''''';
var
  ls:  string;
  ls2: string;
begin
  ls  := #90 + linebreak + #90#91 + somechars + #90;
  ls2 := #$F#$A;
  ls2 := ls + #$1F + hexchars;
end;

procedure stringchars;
const
  boo   = 'Boo';
  hello = 'Hello'#13;
  olla  = #10'Olla!';
var
  ls: string;
begin
  ls := 'Fred';
  ls := #13;
  ls := #12'Fred'#32'Fred'#22;
end;

const
  str1      = ^m;
  hat_foo   = ^a;
  hat_bar   = ^b;
  hat_fish  = ^f;
  hat_wibble = ^q;
  hat_spon  = ^z;
  hat_at    = ^@;
  hat_frown = ^[;
  hat_hmm   = ^\;
  hat_smile = ^];
  hat_hat   = ^^;
  hat_under = ^_;
  hat_eq_nospace = ^=;
  hat_eq_spaceaft = ^=;
  hat_eq_long = ^=^=#0^='foo'^=;

var
  hat1: char = ^h;
  hat2: char = ^j;
  hat3: char = ^m;

procedure hatbaby;
var
  str: string;
  ch:  char;
begin
  str := hat_foo + ^m;
  ch  := ^n;
  str := hat_foo + ^@ + ^] + ^^ + ^- + ^\ + ^[;
end;

procedure testhatcharliteralsinstrings;
var
  str1: string;
begin
  str1 := 'prefix'^m + 'substr2';
  str1 := 'prefix'^m'foo' + 'substr2';
  str1 := 'prefix'^m'foo'#23 + 'substr2'#56;
  str1 := 'prefix'^m'foo'^m'bar'^n + 'substr2'^o;
  str1 := 'prefix'#13^m#12^@'foo'#10^m'bar';
  str1 := ^m;
  str1 := ^m + 'substr2';
  str1 := ^m'foo' + 'substr2';
  str1 := ^m^n^@'foo' + 'substr2';
  str1 := ^m'foo'#23 + 'substr2'#56;
  str1 := ^m'foo'^m'bar'^n + 'substr2'^o;
  str1 := #13^m#12^@'foo'#10^m'bar';
end;

procedure hatequals(const Value: PChar);
const
  hat_eq     = ^=;
  hat_eq_c   = ^='C';
  hat_eq_nil = ^=#0;
  hat_eq_c_nil = ^='C'^=#0^='C'^=#0;
var
  st: string;
begin
  if Value^ = 'C' then
    ShowMessage('See')
  else if (Value^ = #0) then
    ShowMessage('nil')
  else if (Value^ = ^=) then
    ShowMessage('terrence, this is stupid stuff');
  if Value^ = 'C' then
  else if ((Value^) = #0) then
    ShowMessage('nil')
  else if (Value^ = ^=) then
    ShowMessage('terrence, this is stupid stuff');
  st := Value^ + Value^;
  if (Value^ = ^=^=) then
    ShowMessage('meep');
  if (Value^ = ^+^-^^^_) then
    ShowMessage('meep');
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?