BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible to output to cmd window?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Jan
Guest





PostPosted: Mon Jul 28, 2003 3:33 pm    Post subject: Possible to output to cmd window? Reply with quote



Hi all,
Is it possible to output text to the command window when a Gui app is run
from the command line? I have a windows app that can also be run from the
command line. If it is run from command line then I would like to output
some lines of text.

I've figured out how to start a new console window, but this isn't really
what I need. I need to be able to return text to the cmd window that the
app was run from.

Is this possible? If so, any idea how?

thx,
Jan


Back to top
Ignacio Vazquez
Guest





PostPosted: Mon Jul 28, 2003 4:07 pm    Post subject: Re: Possible to output to cmd window? Reply with quote



"Jan" <ngresource (AT) yahoo (DOT) com> wrote in message
3f25425e$1 (AT) newsgroups (DOT) borland.com...
Quote:
I've figured out how to start a new console window, but this isn't really
what I need. I need to be able to return text to the cmd window that the
app was run from.

Is this possible? If so, any idea how?

Try creating a THandleStream with a handle of 1.

Cheers,
Ignacio



Back to top
Jan
Guest





PostPosted: Mon Jul 28, 2003 8:11 pm    Post subject: Re: Possible to output to cmd window? Reply with quote



Thx for the reply, but I tried and could not get THandleStream to work. Do
you happen to have a small example or could redirect me to one?

Thx!
Jan

"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote

Quote:
"Jan" <ngresource (AT) yahoo (DOT) com> wrote in message
3f25425e$1 (AT) newsgroups (DOT) borland.com...
I've figured out how to start a new console window, but this isn't
really
what I need. I need to be able to return text to the cmd window that
the
app was run from.

Is this possible? If so, any idea how?

Try creating a THandleStream with a handle of 1.

Cheers,
Ignacio





Back to top
Jan
Guest





PostPosted: Mon Jul 28, 2003 8:34 pm    Post subject: Re: Possible to output to cmd window? Reply with quote

I am much obliged for your help Smile. I got it to work, but only if the
apptype is console- I want to keep my GUI app though. Do you know of any
way to get output to the command window using {$APPTYPE GUI} that is invoked
from the command line?


"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote

Quote:
"Jan" <ngresource (AT) yahoo (DOT) com> wrote in message
3f25838e$1 (AT) newsgroups (DOT) borland.com...
Thx for the reply, but I tried and could not get THandleStream to work.
Do you happen to have a small example or could redirect me to one?

If the following doesn't work:

var
hs: THandleStream;
const
s: String='Meh';
begin
hs:=THandleStream.Create(1);
hs.Write(s[1], 4);
end;

then try:

var
fs: TFileStream;
const
s: String='Meh';
begin
fs:=TFileStream.Create('CON:', fmOpenWrite);
fs.Write(s[1], 4);
end;

Cheers,
Ignacio

--
Jesus is coming... EVERYONE LOOK BUSY!





Back to top
Jon Tveten
Guest





PostPosted: Tue Jul 29, 2003 1:09 am    Post subject: Re: Possible to output to cmd window? Reply with quote


"Jan" <ngresource (AT) yahoo (DOT) com> wrote:
Quote:
I am much obliged for your help Smile. I got it to work, but only if the
apptype is console- I want to keep my GUI app though. Do you know of any
way to get output to the command window using {$APPTYPE GUI} that is invoked
from the command line?

Hi,

In Project Options|Linker check Create Console Application.

Start your program from a command prompt and then any writeln will be sent to the console where the application was started.

Jon Tveten


Back to top
Jan
Guest





PostPosted: Tue Jul 29, 2003 2:47 pm    Post subject: Re: Possible to output to cmd window? Reply with quote

Well, doing a console app was never a problem- the problem was that I didn't
want a console app, but a dual app. I believe I've managed to get what I
need by doing this:

program Test;

uses
Forms,
Windows,
Myfrm in 'Myfrm.pas' {frmMyfrm};

{$R *.RES}

procedure PerformGUIApp;
begin
Application.Initialize;
Application.CreateForm(TMyfrm, Myfrm);
Application.Run;
end;

procedure PerformConsoleApp;
var
aFrm : TMyfrm;
begin
if AllocConsole then
try
aFrm := TMyfrm.Create(nil);
if aFrm.Process then
writeln('Files processed successfully'#13#10'Press <ENTER> to close
application')
else
writeln('Files did not process successfully'#13#10'Press <ENTER> to
close application');
readln;
finally
aFrm.Free;
FreeConsole;
end;

Application.Terminate;
end;

begin

if ParamCount > 0 then
begin
Application.ShowMainForm := false;
PerformConsoleApp;
end
else
PerformGUIApp;

end.

Thanks to all for your help!
Jan


"Franz-Leo Chomse" <franz-leo.chomse (AT) samac (DOT) de> wrote

Quote:

Apptype Console and a graphical user interface is still possible. The
only difference is that the main window is the console window instead
of the main form. i.e. closing the console window closes the
application.

Regards from Germany

Franz-Leo




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.