Pascal Newline Character 
Author Message
 Pascal Newline Character


Quote:
> Could anyone please tell me what the Pascal equivalent
> of C's "\n" character is?

> TIA to all.

  Just use writeln.  In pascal,

     WRITE('HELLO');   is the same as   printf("HELLO");

  and

     WRITELN('HELLO');   is the same as   printf("HELLO\n");

  > Sam Lane



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character
Could anyone please tell me what the Pascal equivalent
of C's "\n" character is?

TIA to all.



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:

>>Could anyone please tell me what the Pascal equivalent
>>of C's "\n" character is?

>Nope, not with standard Write.  Turbo Pascal, uses the BIOS write
>functions (or direct replacements) which means that control characters,
>well... aren't.  Hence, instead of <CR/LF> (which is 13 and 10) you get
>the ASCII symbol equivalents.

No, you get the control characters - with the Bios routines as well as with
the replacements of the Crt unit. (If you have the RTL that comes with BP 7.0,
you may have a look at the source Crt.Asm to see how some control chars are
handled.) So you can do something like:
  Write('First line'#13#10'Second line'#13#10)

Note however that #13#10 is a Dos specific control code. Unix e.g. uses only
#10, and other systems may have even different newline chars. So if
portability could be an issue (in times where BP compatible compilers for
other platforms are becoming available), don't use these.

This is unlike C's "\n" which is translated by the compiler into the
correct newline code on your platform - BP doesn't do this!

Hope this helps
Frank



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:

> Could anyone please tell me what the Pascal equivalent
> of C's "\n" character is?

> TIA to all.

WriteLn("");  <-- for output

var S : String;

S := #13#10;  <-- for DOS
S := #10;     <-- for Unix



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:

>Could anyone please tell me what the Pascal equivalent
>of C's "\n" character is?

#13#10

const
  newline=#13#10

write(#13#10'Here is a'#13#10'new line.');

Works for me.
--

*THE* PC Demo WWW page:  http://www.cdrom.com/pub/demos/hornet/html/demos.html
The 8086 Compo is OVER!  Results at http://www.cdrom.com/pub/demos/hornet/8086
Make A Computer easy enough for a fool to use, and only fools will use it!



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:
>Could anyone please tell me what the Pascal equivalent
>of C's "\n" character is?

Nope, not with standard Write.  Turbo Pascal, uses the BIOS write
functions (or direct replacements) which means that control characters,
well... aren't.  Hence, instead of <CR/LF> (which is 13 and 10) you get
the ASCII symbol equivalents.


Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character


Quote:
> Could anyone please tell me what the Pascal equivalent
> of C's "\n" character is?

#13#10

writeln('hello...',#13#10,'...world');

.splitbung
--
* TQ 1.0 * The 'Just So Quotes'.
"Hey, imp!" shouted Vlad, the imp hailer.



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:

Sloan)>says:
>>Could anyone please tell me what the Pascal equivalent
>>of C's "\n" character is?

>Nope, not with standard Write.  Turbo Pascal, uses the BIOS write
>functions (or direct replacements) which means that control characters,
>well... aren't.  Hence, instead of <CR/LF> (which is 13 and 10) you get
>the ASCII symbol equivalents.

Not so.  You *do not* get the ASCII equivalents, even when using CRT (which
replaces calls to BIOS with routines to write directly to the screen).  For
example,

  write ('Hello!'#13#10);

is equivalent to

  writeln ('Hello!);

Essentially, for TP, Adding #13#10 to a string provides the same
functionality as \n in C.  Like \n, it doesn't *have* to be at the end of
the line, either:

   writeln ('Hello'#13#10'there!');

will output

Hello
there!

Just remember to place it _outside_ the quotes!

--
Scott F. Earnest            | We now return you to our regularly scheduled



Wed, 18 Jun 1902 08:00:00 GMT  
 Pascal Newline Character

Quote:

> Could anyone please tell me what the Pascal equivalent
> of C's "\n" character is?

Use the "writeln" statement to add a new-line at the end of
the print string. It is identical in function to "write" with
the exception of adding the new-line.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. What's newline in Pascal?

2. converting string characters to char characters

3. BARCODE and send CONTROL CHARACTERS to my printer by DELPHI or Pascal Language

4. HELP ME!!!!!! ASCII Characters in Turbo Pascal 7.0

5. ASCII Characters in Turbo Pascal 7.0

6. How to display ascii character in turbo pascal intragrated environment

7. How to create my own character in Pascal?

8. How to create my own character in Pascal?

9. return character in ascii for pascal HELP!

10. Mandarin characters in Pascal program

11. SQL Query and the '\' character

12. The GB Character Set for BDE

 

 
Powered by phpBB® Forum Software