How do I print a tab character in Pascal?

Gabriel A. Zorrilla picture Gabriel A. Zorrilla · Oct 21, 2010 · Viewed 12.7k times · Source

I'm trying to figure out in all the Internets what's the special character for printing a simple tab in Pascal. I have to format a table in a CLI program and that would be handy.

Answer

Marco van de Voort picture Marco van de Voort · Oct 21, 2010

Single non printable characters can be constructed using their ascii code prefixed with #

Since the ascii value for tab is 9, a tab is then #9. Characters such constructed must be outside literals, but don't need + to concatenate:

E.g.

 const
     sometext  = 'firstfield'#9'secondfield'#13#10;

contains two fields separated by a tab, ended by a carriage return (#13) + a linefeed #10

The ' character can be made both via this route, or shorter by just ending the literal and reopening it:

 const 
    some2 = '''bla''';           // will contain 'bla' with the ticks.
    some3 = 'start''bla''end';   // will contain start'bla'end