开发者

Usage of # in Pascal

Q1: What does this mean: WriteLn (#$0b)?

$0b should hexadecimal like 0x0b, but what about the # sign?

Q2:

x:=readkey;
if ( x = #5) do...

Does #5 开发者_StackOverflowmean five? Then what is the# sign for?

Many thanks.


The # in front of a number represents a character with the indicated value (both decimal, and hex numbers preceded by a $, are accepted). So #5 is the same as chr(5), or CtrlE.


Ah, memories ...

#x is indeed the equivalent of chr(x), like Greg Hewgill said.

I'd like to add a little info.
Extended keys, ie the arrow keys, send zero and the char's code:

  ch := ReadKey;
  if ch = #0 then
  begin // extended key
    ch := ReadKey; // <-- read again to get the actual code
  end else ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜