Sign in Join

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

Mailing lists / lazarus / 2012-01

Hello World program generates a File Not Open runtime error

17 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

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

Antônio
program project1;
{$mode objfpc}{$H+}
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };
begin
  WriteLn('Hello World');
  ReadLn();
end.

Any problem? Am I missing something?

Reply by email

Sven Barth
to Antônio
Ant?nio wrote 17 lines
program project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }; begin WriteLn('Hello World'); ReadLn(); end. Any problem? Am I missing something?

Are you on Windows? Then you must add "{$apptype console}".

Regards,
Sven

Reply by email

Antônio
to Sven Barth

Only on Windows?

Ant?nio

2012/1/29 Sven Barth :

Show quoted text 32 lines
On 29.01.2012 15:31, Ant?nio wrote: > > program project1; > > {$mode objfpc}{$H+} > > uses > ? {$IFDEF UNIX}{$IFDEF UseCThreads} > ? cthreads, > ? {$ENDIF}{$ENDIF} > ? Classes > ? { you can add units after this }; > > begin > ? WriteLn('Hello World'); > ? ReadLn(); > end. > > Any problem? Am I missing something? Are you on Windows? Then you must add "{$apptype console}". Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sven Barth
to Antônio
Ant?nio wrote 27 lines
Only on Windows? Ant?nio 2012/1/29 Sven Barth: > On 29.01.2012 15:31, Ant?nio wrote: >> >> program project1; >> >> {$mode objfpc}{$H+} >> >> uses >> {$IFDEF UNIX}{$IFDEF UseCThreads} >> cthreads, >> {$ENDIF}{$ENDIF} >> Classes >> { you can add units after this }; >> >> begin >> WriteLn('Hello World'); >> ReadLn(); >> end. >> >> Any problem? Am I missing something? > > > Are you on Windows? Then you must add "{$apptype console}".

Windows and perhaps OS/2 are the only systems that differentiate between GUI and console applications.

Regards,
Sven

Reply by email

Antônio
to Sven Barth

Maybe something could be done to make things easier for Windows users?

Ant?nio

2012/1/29 Sven Barth :

Show quoted text 47 lines
On 29.01.2012 15:43, Ant?nio wrote: > > Only on Windows? > > Ant?nio > > 2012/1/29 Sven Barth: >> >> On 29.01.2012 15:31, Ant?nio wrote: >>> >>> >>> program project1; >>> >>> {$mode objfpc}{$H+} >>> >>> uses >>> ? {$IFDEF UNIX}{$IFDEF UseCThreads} >>> ? cthreads, >>> ? {$ENDIF}{$ENDIF} >>> ? Classes >>> ? { you can add units after this }; >>> >>> begin >>> ? WriteLn('Hello World'); >>> ? ReadLn(); >>> end. >>> >>> Any problem? Am I missing something? >> >> >> >> Are you on Windows? Then you must add "{$apptype console}". Windows and perhaps OS/2 are the only systems that differentiate between GUI and console applications. Regards, Sven -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

ik
to Antônio
Ant?nio wrote
Maybe something could be done to make things easier for Windows users?

Sure, they can move to Linux :)

But you can fill in a bug report and request to add the the templates and IFDEF for windows that add console mode, or something like that

Show quoted text 59 lines
Ant?nio 2012/1/29 Sven Barth : > On 29.01.2012 15:43, Ant?nio wrote: >> >> Only on Windows? >> >> Ant?nio >> >> 2012/1/29 Sven Barth: >>> >>> On 29.01.2012 15:31, Ant?nio wrote: >>>> >>>> >>>> program project1; >>>> >>>> {$mode objfpc}{$H+} >>>> >>>> uses >>>> {$IFDEF UNIX}{$IFDEF UseCThreads} >>>> cthreads, >>>> {$ENDIF}{$ENDIF} >>>> Classes >>>> { you can add units after this }; >>>> >>>> begin >>>> WriteLn('Hello World'); >>>> ReadLn(); >>>> end. >>>> >>>> Any problem? Am I missing something? >>> >>> >>> >>> Are you on Windows? Then you must add "{$apptype console}". > > > Windows and perhaps OS/2 are the only systems that differentiate between GUI > and console applications. > > > Regards, > Sven > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120129/ffcdf8cc/attachment-0001.html>

Reply by email

Sven Barth
to Antônio: Maybe something could be done to make things easier for Windows users? Ant?nio 2012/1/29…

Maybe a "simple console application" project could be added to Lazarus or "{$apptype console}" could be added by default to "custom program" projects.

It will not be changed however, that console I/O is possible without {$apptype console}, because it was only rather recently changed to be this way (because this is how users expect Windows applications to behave).

Regards,
Sven

Ant?nio wrote 41 lines
Maybe something could be done to make things easier for Windows users? Ant?nio 2012/1/29 Sven Barth: > On 29.01.2012 15:43, Ant?nio wrote: >> >> Only on Windows? >> >> Ant?nio >> >> 2012/1/29 Sven Barth: >>> >>> On 29.01.2012 15:31, Ant?nio wrote: >>>> >>>> >>>> program project1; >>>> >>>> {$mode objfpc}{$H+} >>>> >>>> uses >>>> {$IFDEF UNIX}{$IFDEF UseCThreads} >>>> cthreads, >>>> {$ENDIF}{$ENDIF} >>>> Classes >>>> { you can add units after this }; >>>> >>>> begin >>>> WriteLn('Hello World'); >>>> ReadLn(); >>>> end. >>>> >>>> Any problem? Am I missing something? >>> >>> >>> >>> Are you on Windows? Then you must add "{$apptype console}". > > > Windows and perhaps OS/2 are the only systems that differentiate between GUI > and console applications.

Reply by email

Mattias Gaertner
to Antônio
Show quoted text 6 lines
> But you can fill in a bug report and request to add the the templates and > IFDEF for windows that add console mode, or something like that I think this is a good idea. {$IFDEF Windows}{$apptype console}{$ENDIF}

These things can be done by the IDE by passing the right -W option. I'm not sure about the details. Some of the -W options have changed. I will ask on the FPC list, when -WG, -WC, -WF, -WT should be passed.

Mattias

Reply by email

Mattias Gaertner
to Antônio: program project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads}…
Show quoted text 17 lines
program project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }; begin WriteLn('Hello World'); ReadLn(); end. Any problem? Am I missing something?

Please check Project options / Compiler options / Linking / Target OS specif options.
Make sure the -WG is not checked.

Mattias

Reply by email

Antônio
to Mattias Gaertner

You are right, unchecking -WG it is OK.

Ant?nio

2012/1/29 Mattias Gaertner :

Show quoted text 32 lines
On Sun, 29 Jan 2012 12:31:51 -0200 Ant?nio wrote: > program project1; > > {$mode objfpc}{$H+} > > uses > ? {$IFDEF UNIX}{$IFDEF UseCThreads} > ? cthreads, > ? {$ENDIF}{$ENDIF} > ? Classes > ? { you can add units after this }; > > begin > ? WriteLn('Hello World'); > ? ReadLn(); > end. > > Any problem? Am I missing something? Please check Project options / Compiler options / Linking / Target OS specif options. Make sure the -WG is not checked. Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Curt Carpenter
to Antônio
Ant?nio wrote 42 lines
You are right, unchecking -WG it is OK. Ant?nio 2012/1/29 Mattias Gaertner: > On Sun, 29 Jan 2012 12:31:51 -0200 > Ant?nio wrote: > >> program project1; >> >> {$mode objfpc}{$H+} >> >> uses >> {$IFDEF UNIX}{$IFDEF UseCThreads} >> cthreads, >> {$ENDIF}{$ENDIF} >> Classes >> { you can add units after this }; >> >> begin >> WriteLn('Hello World'); >> ReadLn(); >> end. >> >> Any problem? Am I missing something? > Please check Project options / Compiler options / Linking / Target OS > specif options. > Make sure the -WG is not checked. > > Mattias > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Mattias:
Could you tell us where we find this in the documentation? I'm sure it's there -- I'd just like to add it to my notes since I'll probably encounter the same problem at some point :-)
Thanks,
Curt Carpenter

Reply by email

Mattias Gaertner
to Curt Carpenter
Show quoted text 9 lines
[...] >> Please check Project options / Compiler options / Linking / Target OS >> specif options. >> Make sure the -WG is not checked. > Mattias: Could you tell us where we find this in the documentation? I'm sure it's there -- I'd just like to add it to my notes since I'll probably encounter the same problem at some point :-)
You will get this only if you start with an Application and then
decide to do some console stuff.

It's explained in the Lazarus book. The -WG option is explained in the Free Pascal book, the FPC "User's guide", the FAQ and various other places.
I added a hint to the FAQ and the tutorial.

Mattias

Reply by email

waldo kitty
to Antônio: I think this is a good idea. {$IFDEF Windows}{$apptype console}{$ENDIF} Ant?nio
Ant?nio wrote 6 lines
> But you can fill in a bug report and request to add the the templates and > IFDEF for windows that add console mode, or something like that I think this is a good idea. {$IFDEF Windows}{$apptype console}{$ENDIF}

manually or automatic? i don't know that i can remember to do this for all the apps that i'm headed towards that i develop and test on winwhatever with the ultimate goal of simply compiling on OS/2 and placing in production... this should not have to be anything manually handled... IMHO of course...

Reply by email

waldo kitty
to Mattias Gaertner: On Sun, 29 Jan 2012 13:12:38 -0600 You will get this only if you start with an…
Mattias Gaertner wrote 17 lines
On Sun, 29 Jan 2012 13:12:38 -0600 Curt Carpenter wrote: > [...] >>> Please check Project options / Compiler options / Linking / Target OS >>> specif options. >>> Make sure the -WG is not checked. >> > Mattias: > Could you tell us where we find this in the documentation? I'm sure > it's there -- I'd just like to add it to my notes since I'll probably > encounter the same problem at some point :-) You will get this only if you start with an Application and then decide to do some console stuff. It's explained in the Lazarus book.

is there now an english translation version available? i know it was discussed some time back but i've not seen anything about its availability since then :?

Reply by email

Mattias Gaertner
to waldo kitty: manually or automatic? i don't know that i can remember to do this for all the apps that…
Show quoted text 12 lines
On 1/29/2012 10:42, Ant?nio wrote: >> But you can fill in a bug report and request to add the the templates and >> IFDEF for windows that add console mode, or something like that > > I think this is a good idea. > > {$IFDEF Windows}{$apptype console}{$ENDIF} manually or automatic? i don't know that i can remember to do this for all the apps that i'm headed towards that i develop and test on winwhatever with the ultimate goal of simply compiling on OS/2 and placing in production... this should not have to be anything manually handled... IMHO of course...

It was an user error.
You don't need to add the directives.

Mattias

Reply by email

Felipe Monteiro de Carvalho
to waldo kitty: is there now an english translation version available? i know it was discussed some time…
waldo kitty wrote
is there now an english translation version available? i know it was discussed some time back but i've not seen anything about its availability since then :?

Yes, the english version is available since aprox. April, last year. In the Lazarus website: http://www.lazarus.freepascal.org/ In the left side there is: "Bookstore Lazarus, the complete guide"

Which is a link to:
http://www.blaisepascal.eu/index.php?actie=./subscribers/lazarusbookinfoEnglish

Felipe Monteiro de Carvalho

Reply by email