A simple console application
The following program is a simple console program that you can compile and run on the command line.
PRogramgreeting;
{$APPTYPECONSOLE}
varMyMessagestring;
Begin
MyMessage:='Helloworld!';
Writeln(MyMessage);
end.
The first line explains that the program is called Greeting. {$APPTYPECONSOLE} tells the compiler to be a console application that runs on the command line. The following line defines a variable of type string called MyMessage. (delphi has real string data type), this program passes the string "Helloworld!" to the MyMessage variable, and then uses the Writeln command to output the contents of MyMessage to the standard output device. (Writeln is defined in System unit files, which is automatically included by the compiler in many applications)
Save to a file of type greeting.pas or greeting.dpr, and then enter the following command to compile
dcc32greeting
To generate a win32 executable file
dccilgreeting
Generate a .net executable file.
Apart from its simplicity, this example is somewhat different in many ways from the programs you write in the borland development tool. First, it is a console application. Borland development tools are often used to develop applications that are most commonly used in graphical interfaces, so you will not be able to use the Writeln command normally. In addition, all routines are in a separate file. In a typical graphical image interface program, the line of the program at the beginning of the example will be placed in a separate project file that does not include any actual logical programs, unlike a few in the unit file that are called to the program definition.