Delphi ^A 语法:记录的、隐含的还是未记录的? [英] Delphi ^A syntax: Documented, implied, or undocumented?

查看:18
本文介绍了Delphi ^A 语法:记录的、隐含的还是未记录的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我通过一个例子来解释.在Delphi中,你可以写

Let me explain by an example. In Delp you can write

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = ^C then
    ShowMessage('The user wants to copy something.')
  else if Key = ^V then
    ShowMessage('The user wants to paste.')
end;

检查 Ctrl+C 和 Ctrl+V 键盘命令.事实上,同样的语法适用于 Ctrl+A,其中 A 是 any 字符,而且——当然——你也可以使用 case 语句代替 如果s.您甚至可以执行 ShowMessage(^A),因此,显然,^A 被视为 char.

to check for Ctrl+C and Ctrl+V keyboard commands. In fact, the same syntax works for Ctrl+A, where A is any character, and -- of course -- you can also use a case statement instead of ifs. You can even do ShowMessage(^A), so, apparently, ^A is considered a char.

但是,在浏览 官方 Delphi 文档 时,我找不到对此的任何参考句法.但也许 ^A 语法是如此普遍以至于它被理解为底层纯文本文件格式的一部分?或者它只是 Delphi 编程语言的一个未记录的特性?(请注意,上述结构实际上用于 RTL/VCL 源代码.但是,当然,Embarcadero 和 Embarcadero 单独允许使用未记录的功能,如果存在的话.)

However, when browsing the official Delphi documentation, I cannot find any reference to this syntax. But maybe the ^A syntax is so common that it is understood as a part of the underlying plain text file format? Or is it simply an undocumented feature of the Delphi programming language? (Notice that the above constructions are actually used in the RTL/VCL source code. But, of course, Embarcadero, and Embarcadero alone, is allowed to use undocumented features, if any such exists.)

推荐答案

这是很久以前的转义字符,使您能够以更易读的方式为控制字符设置 const.

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.

这定义了一个值为 #3 的 Char 常量,然后在 Borland Pascal 7 中写入 3,我记得在那之前几年也看到过.

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

我刚刚查看了 Turbo Pascal 5.0 和 Borland Pascal 7.0 语言指南,但找不到它,所以它似乎没有记录.

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

我记得这是 Borland 的东西,只是 checked:它不是ISO Pascal 标准(以前是 ANSI Pascal 标准,感谢 Sertac 注意到这一点).

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).

记录在 Free Pascal 文档.

SGI 使用反斜杠作为转义字符,如 根据他们的文档.

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

更多我找到了 在 Delphi in a NutshellDelphi Basics 网站.

找到它:刚刚在 Turbo Pascal 3 参考手册.

--杰罗恩

这篇关于Delphi ^A 语法:记录的、隐含的还是未记录的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆