Solved

{$APPTYPE CONSOLE} ?

Posted on 2003-11-01
3
852 Views
Last Modified: 2008-02-01
What is {$APPTYPE CONSOLE}, and how do you make a program that just executes in a dos window if you do not want to use forms in your project?
0
Comment
Question by:herd_bone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
DeNavigator earned 65 total points
ID: 9662394
You just said it yourself! :)
To make a Console application:
Choose New -> Other -> Console Application
in your Delphi IDE.
{$APPTYPE CONSOLE} is a compiler directive, which tells the compiler what kind of program to generated.
0
 

Author Comment

by:herd_bone
ID: 9662400
thanks main!
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9662492
Hi,

{$APPTYPE CONSOLE} tells the Delphi compiler that you're doing a
console app, without forms, executing in a DOS window.

When you're using this kind of app, the compiler AllocateConsole for you.
You can then DeallocateConsole and AllocateConsole if you want a better
configuration or a personalized one.

You create a new console application through the File|New... dialog,
choosing "console application".

The big advantage of console apps is that you can still use Delphi
non visual components and datamodules.

See this:

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

begin
  { Insert code here }
end.

Now, imagine we created a datamodule called TMyDataModule in
unit "uMyDataModule".

You can modify the former in:

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, uMyDataModule;

begin
  { Insert code here }
  with TMyDataModule.Create( nil ) do
  begin
    // Method calls here
    Free;
  end;
end.

To gather parameters you can use ParamStr as you
would do with plain Windows applications.

ParamStr directly descends from the corresponding
Turbo Pascal instruction.

Special considerations should be done in several areas:

1) I/O handlers: it's my opinion that standard handlers should
never be overdriven to new sources. If you want to have other
kinds of I/O devices you should use parameters or redirection at the
command prompt level or through CreateProcess API.

2) You won't be able to use visual controls( of course ) for the lack of
forms, but you'll be able to use the Windows APIs.

3) To make a TP-Like program you'll need a WinCrt clone.
There're a number out there, I'd suggest either the Ben Ziegler one or a
free one whose name I don't recall right now.

4) Remember that at the end of the game a console app is simply a
special type of Windows app, thus you'll lose things like Port and Mem
with their extended versions( PortW,PortL, etc ).

HTH,

Andrew
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question