Board index » delphi » Writing a 32 bit command line utility in Delphi?

Writing a 32 bit command line utility in Delphi?

I've written a command line utility here which manipulates link files.

It all works wonderfully well, but I'm using a dialog box for message output.

Is there some way to write the output back to the DOS box from which it was
called, like the Windows 95 supplied command line utilities?

Thanks in anticipation,
--
Peter Summers                       http://www.summers.auz.net/peter/
Cardiology Department               Phone   (+613/03) 9342 8727 (B)
Royal Melbourne Hospital                    (+613/03) 9387 4203 (H)
AUSTRALIA  3050                     Fax     (+613/03) 9347 2808

 

Re:Writing a 32 bit command line utility in Delphi?


In article <5eu2te$...@news.unimelb.EDU.AU> PE...@cardiology.medrmh.unimelb.edu.au (Peter Summers, Computer Engineer, Cardiology) writes:

Quote
>I've written a command line utility here which manipulates link files.
>It all works wonderfully well, but I'm using a dialog box for message output.
>Is there some way to write the output back to the DOS box from which it was
>called, like the Windows 95 supplied command line utilities?

Try this:

Make a file Hello.pas

begin
writeln('Hello World');
end.

Then go, from DOS,

DCC32 -CC HELLO

and run it.

If you want to work from within the IDE you will have to add the
{$APPTYPE CONSOLE} compiler directive.

Mark Horridge email: mark.horri...@buseco.monash.edu.au

Re:Writing a 32 bit command line utility in Delphi?


Quote
>Is there some way to write the output back to the DOS box from which it was
>called, like the Windows 95 supplied command line utilities?

Yes (I assume you're using Delphi 2.0). If your program is already set up to
be a console application (Project|Options|Linker|Generate console
application), then all you have to do is use WriteLn or Write statements. If
you aren't writing a console app, then you can try calling AllocConsole()
before using WriteLn or Write, but I think that will create a new console. You
can also do colored text, but I won't go into that here. For more info, search
the Delphi Help for "AllocConsole", then click "Group" up at the top. That
will take you to the Console Group, which has the Console API documentation.
Just read through the various functions and try different things.

              _   __   -----------------------------------------------
  .,,        ( `-'  \  | Tyler Dauwalder                             |
 C:::]|||||||||() | |  | dauwa...@televar.com                        |
  `'`        (_.-.__/  | http://www.televar.com/~dauwaldt/index.html |
                       -----------------------------------------------

Re:Writing a 32 bit command line utility in Delphi?


For what it's worth, you can still use forms and such from a console app.
This makes it possible to have graphical forms, etc., AND a terminal
screen...  This is wonderful, for example, when combined with a few
{$IFDEF}'s for debugging purposes.  You can write debug info into the
terminal window, then just compile it out when you're ready to ship.
Slick.

--
David S. Becker
ADP Dealer Services (Plaza R&D)
d...@plaza.ds.adp.com
(503)402-3236

Tyler Dauwalder <dauwa...@televar.com> wrote in article
<5f0kp0$...@bartlett.televar.com>...

Quote
> >Is there some way to write the output back to the DOS box from which it
was
> >called, like the Windows 95 supplied command line utilities?

> Yes (I assume you're using Delphi 2.0). If your program is already set up
to
> be a console application (Project|Options|Linker|Generate console
> application), then all you have to do is use WriteLn or Write statements.
If
> you aren't writing a console app, then you can try calling AllocConsole()
> before using WriteLn or Write, but I think that will create a new
console. You
> can also do colored text, but I won't go into that here. For more info,
search
> the Delphi Help for "AllocConsole", then click "Group" up at the top.
That
> will take you to the Console Group, which has the Console API
documentation.
> Just read through the various functions and try different things.

>               _   __   -----------------------------------------------
>   .,,        ( `-'  \  | Tyler Dauwalder                             |
>  C:::]|||||||||() | |  | dauwa...@televar.com                        |
>   `'`        (_.-.__/  | http://www.televar.com/~dauwaldt/index.html |
>                        -----------------------------------------------

Re:Writing a 32 bit command line utility in Delphi?


Sorry, made a usenet faux pas... (bad Adrian, bad)
add the following line to your app:

{$APPTYPE CONSOLE}

my apologies...

Adrian Kwong <a.kw...@ieee.ca> wrote in article
<01bc2429$7cd404e0$e15ab5cf@lioness>...

Quote

> ie:

> Program HelloWorld;

{$APPTYPE CONSOLE}  //*************add this line here***********
Quote

> uses
>    Windows; //not necessary actually for this simple proggy

> begin
>    writeln('Hello world.');
>    readln;
> end.

Re:Writing a 32 bit command line utility in Delphi?


Peter Summers, Computer Engineer, Cardiology
<PE...@cardiology.medrmh.unimelb.edu.au> wrote in article
<5eu2te$...@news.unimelb.EDU.AU>...

Quote
> I've written a command line utility here which manipulates link files.

> It all works wonderfully well, but I'm using a dialog box for message
output.

> Is there some way to write the output back to the DOS box from which it
was
> called, like the Windows 95 supplied command line utilities?

Create a new project.
Close the Form and it's unit file. (or use the unitfile if you want to keep
object oriented)
View|Project Source.
Delete the "uses Forms".
Add whatever Units you need like "uses Windows, SysUtil, Winsock;"
Delete the 3 lines between begin and end.
Type your own code in there instead.

ie:

Program HelloWorld;

uses
   Windows; //not necessary actually for this simple proggy

begin
   writeln('Hello world.');
   readln;
end.

Now you can push run.  Press enter to quit your app.

--
Adrian Kwong

Re:Writing a 32 bit command line utility in Delphi?


Quote
>I've written a command line utility here which manipulates link files.
>It all works wonderfully well, but I'm using a dialog box for message output.
>Is there some way to write the output back to the DOS box from which it was
>called, like the Windows 95 supplied command line utilities?

        Did you try WriteLn?

--
Deploy your Delphi Apps ON the web. No more CGI/HTML. Just Delphi.
Does not require ActiveX or any Plugins.
Don't believe it? Come see BIOLIFE (The one that comes with Delphi) on the web.
http://www.shoresoft.com

Other Threads