tags:

views:

380

answers:

5

For example:

x := #123;

I tried to search around Google but I simply have no idea what this means.

+5  A: 

It's a character (Char type) of the ordinal value 123.

TOndrej
+9  A: 

IIRC it means a character value of the number (eg. #32 -> space).

jpalecek
#123 is the same thing as Chr(123), except it's a literal character constant instead of a builtin system function (Chr).
Warren P
+2  A: 

It is an extention to standard Pascal, Borland Pascal accepts the pound sign ('#') followed immediately by a decimal number between 0 and 255 as a single character with that code.

SQLMenace
Well, in Delphi 2009+ all strings are Unicode, so you are not restricted to codes between 0 and 255 any more. For example, #$222b is the integral sign. (In Delphi, $ is the hexadecimal prefix.)
Andreas Rejbrand
You aren't restricted to that in prior versions, either, @Andreas. Delphi supported Unicode for more than a decade before Delphi 2009.
Rob Kennedy
Delphi supported WideChar literals for more than a decade?
Warren P
@Rob Kennedy: But you could not write Caption := #$222b and get an integral sign as the form's caption, right?
Andreas Rejbrand
Yes, @Warren. Delphi 4 supported them, and that was released in 1998. Andreas, you're right.
Rob Kennedy
+2  A: 

It's character code. #97 is equivalent to 'a' etc etc

A chart can be see here.

CheesePls
What does == mean? In Delphi, you use := for assignments and = when testing for equality. The operator == does not exist.
Andreas Rejbrand
sorry about that. == means "equivalent to". Edited answer for clarity
CheesePls
OK, so it was not intended to be a Delphi expression. I see!
Andreas Rejbrand
Nope. It's been so long since I've used Pascal I forgot about =
CheesePls
A: 

As other have mentioned it's a character code, I most often see them used for line breaks in messages, or other control character such as Tab (#9)

ShowMessage('Error:'#13#10'Something terrible happened')

Strangely it's not necessary to concatinate a string involving these.

JamesB
it's better to use the sLineBreak for that functionality though.
Chris J