Delphi ^A syntax: Documented, implied, or undocumented?

后端 未结 2 965
梦毁少年i
梦毁少年i 2020-12-29 01:42

Let me explain by an example. In Delphi, you can write

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = ^C then
    ShowMessag         


        
相关标签:
2条回答
  • 2020-12-29 02:14

    This is a known undocumented feature. But then again, the latest official syntax documentation is from delphi 7.

    0 讨论(0)
  • 2020-12-29 02:23

    This is from long ago as an escape character to enable you to have consts for control characters in a more readable way.

    const
      CtrlC = ^C;
    begin
      Write(Ord(CtrlC));
    end.
    

    This defines a Char constant with value #3, then writes 3 in Borland Pascal 7, and I remember seeing it years before that too.

    I just checked the Turbo Pascal 5.0 and Borland Pascal 7.0 languages guides, but could not find it, so it seems undocumented.

    Edit: I do remember this was a Borland thing, and just checked: it is not part of the ISO Pascal standard (formerly this was ANSI Pascal Standard, thanks Sertac for noticing this).

    It is documented in the Free Pascal documentation.

    SGI uses the backslash as escape character, as per their docs.

    More Edit: I found it documented in Delphi in a Nutshell and the Delphi Basics site.

    Found it: Just found it on page 37 of the Turbo Pascal 3 Reference Manual.

    --jeroen

    0 讨论(0)
提交回复
热议问题