Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-07

Bug or feature ?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ched

Hello All,

I have a long code which include lines for writing stuffs into an assigned writable text-file F.

    WRITELN(F: 'Hello');
    WRITELN(F, 'Hello');

The code can be compiled with 3.2.2 in i386/windows and i386/linux and runs both ... i'm wondering if the first line is really legal... Any advice ?

Cheers, Ched'.

Ched
to DougC

Le 27.07.2022 à 17:41, DougC via fpc-pascal a écrit :

WRITELN(F: 'Hello'); is not proper Pascal.

Yes, Doug, I agree ; but it is compiled with no warning and runs perfectly. Now, why the compiler do not complain... ?

Cheers, Ched'

Sven Barth
to Ched: I have a long code which include lines for writing stuffs into an assigned writable…
Ched wrote 12 lines
Hello All, I have a long code which include lines for writing stuffs into an assigned writable text-file F.    WRITELN(F: 'Hello');    WRITELN(F, 'Hello'); The code can be compiled with 3.2.2 in i386/windows and i386/linux and runs both ... i'm wondering if the first line is really legal... Any advice ?

Write(), WriteLn() and WriteStr() (and Str()) allow to adjust the way a numerical value is written by using additional parameters delimited by colons: VarToOutput:NumChars[:Decimals] (see
https://www.freepascal.org/docs-html/current/rtl/system/write.html ). That it nevertheless compiles correctly and executes as "Writeln(F, 'Hello')" is due to a bug in the handling of the parameters. So, please report a bug with a complete example that should fail.

Regards,
Sven