We help IT Professionals succeed at work.

Anyone knows where to get more details on this #13#10?

ivylnm asked
Medium Priority
Last Modified: 2010-04-06
I am wondering where I can find more details on how to use the # such as #13 or #10 to control the output of my text printing.  I would want to know more like how to have tab space and etc.  Please guide.
Watch Question

Most printer manufactures have the control character sets in the printer's manual.  You may even be able to download the info from their website.

I know years ago there used to be really two standards for printers - Epson emulation and IBM emulation.  That was in the 9pin/24pin Dotmatrix days.  Now you've got to cater for dotmatrix, laser, ink, thermal etc.  Each printer can be slightly different.  However you can generaly get most of the functionality just using the Epson control set.

Are you aiming to target just one printer in your program, or a lot of different types?


Just to clarify, though, the # symbol lets you insert any ASCII char into a string - whether it's visible or not.  So if you want to insert, say, a tab all you have to do is know that it's ASCII value is 9 and you can write 'Hi'#9'bye' to get the same as 'Hi     bye'. The delphi help file does talk a little about this, I've clipped he relevant portion below:

A character string, also called a string literal or string constant, consists of a quoted string, a control string, or a combination of quoted and control strings. Separators can occur only within quoted strings.
A quoted string is a sequence of up to 255 characters from the extended ASCII character set, written on one line and enclosed by apostrophes. A quoted string with nothing between the apostrophes is a null string. Two sequential apostrophes in a quoted string denote a single character, namely an apostrophe. For example,

'BORLAND'           { BORLAND }

'You''ll see'       { You'll see }
''''                { ' }
''                  { null string }
' '                 { a space }

A control string is a sequence of one or more control characters, each of which consists of the # symbol followed by an unsigned integer constant from 0 to 255 (decimal or hexadecimal) and denotes the corresponding ASCII character. The control string


is equivalent to the quoted string


You can combine quoted strings with control strings to form larger character strings. For example, you could use

'Line 1'#13#10'Line 2'

to put a carriage-return?line-feed between ?Line 1? and ?Line 2?. However, you cannot concatenate two quoted strings in this way, since a pair of sequential apostrophes is interpreted as a single character. (To concatenate quoted strings, use the + operator or simply combine them into a single quoted string.)
A character string?s length is the number of characters in the string. A character string of any length is compatible with any string type and with the PChar type. A character string of length 1 is compatible with any character type, and, when extended syntax is enabled ({$X+}), a nonempty character string of length n is compatible with zero-based arrays and packed arrays of n characters. For more information about string types, see String types.

Also, you can get the ASCII value of a char by calling ord, so ord('a') = 97 and #97 = 'a'.

Just some very little additions to Mike's complete comment:

chr(97) = #97
#13#10 = #$D#$A = chr(13) + chr(10) = chr($D) + chr($A)

#9 = tab
#13 = #$D = new line
#10 = #$A = line feed

Most text editors (e.g. normal edit and memo controls) want to have #13#10 for a line break. But richEdit controls want to have only one of them, don't remember right now which one it was...

Regards, Madshi.
Hi Madshi.  #13 I think you'll find from memory.

The SQL to some databases do not recognize '' as null, but the SQL must state "<fieldname> is null"

Explore More ContentExplore courses, solutions, and other research materials related to this topic.