Solved

{$APPTYPE CONSOLE} ?

Posted on 2003-11-01
3
826 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
PDF library for Delphi 2 89
problem when i try to pack my dll file with upx 9 63
Sending Gmail through Delphi 3 69
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now