1. PascalProgramBasic Structure
First, explain the basic structure of the PASCAL program (note in advance that the comments in Pascal are included in ):
Program program name; {the name that identifies the program, which can be omitted. However, using a readable program name can clearly display the functions implemented by the program .}
Uses call unit {when the program uses a variable, function, or process in another unit, it needs to make a call declaration for the unit here, let the compiler know the sources of the "unfamiliar" variables, functions, or processes. Generally, the program must reference the CRT unit, because it is responsible for the input and output of the program through the monitor}
Const
{Constant definition}
VaR
{Variable definition}
Begin
{Program subject definition}
End;
You can use read (or readln) and write (or writeln) to interact with input and output. The difference between read and readln is that the latter will automatically wrap the output string, this also applies to write and writeln.
2. Compile a PASCAL program
The function we want to implement now is to display a string "Hello, world!" on the screen !". In fact, it only involves the definition and output of a string. In the integrated environment of Turbo Pascal, select new in the File menu to create a new program. In the new edit box, enter the following program:
Program Hello;
Uses CRT;
VaR
{Variable definition}
Mystring: string;
Begin
{Variable assignment}
Mystring: = 'Hello, world! ′;
{Call writeln to output on screen}
Writeln (mystring );
End;