Using # in Pascal

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

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

2:

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

Does #5 mean five? Then what is the # sign for?

Many thanks.

+7
pascal
source share
2 answers

# before the number represents the character with the specified value (both decimal and hexadecimal numbers preceded by the $ character). So #5 same as chr(5) or Ctrl E.

+7
source share

Ah, memories ...

#x really equivalent to chr(x) , for example, Greg Hugill .

I want to add some information.
Extended keys, i.e. arrow keys, send zero and char code:

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

All Articles