Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of # in Pascal

Tags:

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 mean five? Then what is the# sign for?

Many thanks.

like image 622
Denis Petau Avatar asked Mar 11 '10 09:03

Denis Petau


2 Answers

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.

like image 149
Greg Hewgill Avatar answered Dec 15 '22 06:12

Greg Hewgill


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 ...
like image 27
Nick Dandoulakis Avatar answered Dec 15 '22 08:12

Nick Dandoulakis