Delphi and Kylix

Moderators: pritaeas
Number of threads: 7244
Number of posts: 19051

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Writeln or ShowMessage Posted by johovishta on 9 Oct 2004 at 5:26 PM
Hi,
I am trying to make my life easier and write a generic error returning function.....so I dont have to rewrite modules depending on whether it will be a command line program or if its a GUI program (Yes I know command line programs can use ShowMessage...but thats not cool!)

So heres the question

How can I get a function to tell whether the program it is being run inside is a console application or a windowed program?

Cheers,
Johovishta
Report
Re: Writeln or ShowMessage Posted by zibadian on 9 Oct 2004 at 7:37 PM
: Hi,
: I am trying to make my life easier and write a generic error returning function.....so I dont have to rewrite modules depending on whether it will be a command line program or if its a GUI program (Yes I know command line programs can use ShowMessage...but thats not cool!)
:
: So heres the question
:
: How can I get a function to tell whether the program it is being run inside is a console application or a windowed program?
:
: Cheers,
: Johovishta
:
Here is a very crude method, but it works:
  try
    writeln('This program is a console program');
  except
    ShowMessage('This program is a GUI program');
  end;

If you use writeln() with the Output file inside a GUI program, you will get a I/O 103 error.
A better alternative is to check if the Output file variable is created or not, but I don't know how to code that.
Report
Re: Writeln or ShowMessage Posted by johovishta on 9 Oct 2004 at 8:54 PM
: : Hi,
: : I am trying to make my life easier and write a generic error returning function.....so I dont have to rewrite modules depending on whether it will be a command line program or if its a GUI program (Yes I know command line programs can use ShowMessage...but thats not cool!)
: :
: : So heres the question
: :
: : How can I get a function to tell whether the program it is being run inside is a console application or a windowed program?
: :
: : Cheers,
: : Johovishta
: :
: Here is a very crude method, but it works:
:
:   try
:     writeln('This program is a console program');
:   except
:     ShowMessage('This program is a GUI program');
:   end;
: 

: If you use writeln() with the Output file inside a GUI program, you will get a I/O 103 error.
: A better alternative is to check if the Output file variable is created or not, but I don't know how to code that.
:

Thanks Zibidian...
works fine but is a bit crude ..Oh well who will know but you and I :)

Report
Re: Writeln or ShowMessage Posted by zibadian on 14 Oct 2004 at 3:25 AM
: : : Hi,
: : : I am trying to make my life easier and write a generic error returning function.....so I dont have to rewrite modules depending on whether it will be a command line program or if its a GUI program (Yes I know command line programs can use ShowMessage...but thats not cool!)
: : :
: : : So heres the question
: : :
: : : How can I get a function to tell whether the program it is being run inside is a console application or a windowed program?
: : :
: : : Cheers,
: : : Johovishta
: : :
: : Here is a very crude method, but it works:
: :
: :   try
: :     writeln('This program is a console program');
: :   except
: :     ShowMessage('This program is a GUI program');
: :   end;
: : 

: : If you use writeln() with the Output file inside a GUI program, you will get a I/O 103 error.
: : A better alternative is to check if the Output file variable is created or not, but I don't know how to code that.
: :
:
: Thanks Zibidian...
: works fine but is a bit crude ..Oh well who will know but you and I :)
:
:
I have found a better way: the IsConsole global variable.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.