Difference between revisions of "Hello, World"

From Lazarus wiki
m
m (Text replace - "delphi>" to "syntaxhighlight>")
Line 6: Line 6:
  
 
If you have no idea how to do this, return to the Table of Contents. Earlier lessons explain what a compiler is, give links to downloadable compilers, and walk you through the installation of an open-source Pascal compiler on Windows.
 
If you have no idea how to do this, return to the Table of Contents. Earlier lessons explain what a compiler is, give links to downloadable compilers, and walk you through the installation of an open-source Pascal compiler on Windows.
<delphi>
+
<syntaxhighlight>
 
program Hello;
 
program Hello;
 
begin
 
begin
 
   writeln ('Hello, world.')
 
   writeln ('Hello, world.')
 
end.  
 
end.  
</delphi>
+
</syntaxhighlight>
  
 
The output on your screen should look like:
 
The output on your screen should look like:
Line 17: Line 17:
  
 
If you're running the program in an IDE, you may see the program run in a flash, then return to the IDE before you can see what happened. See the bottom of the previous lesson for the reason why. One suggested solution, adding a readln to wait for you to press Enter before ending the program, would alter the "Hello, world" program to become:
 
If you're running the program in an IDE, you may see the program run in a flash, then return to the IDE before you can see what happened. See the bottom of the previous lesson for the reason why. One suggested solution, adding a readln to wait for you to press Enter before ending the program, would alter the "Hello, world" program to become:
<delphi>
+
<syntaxhighlight>
 
program Hello;
 
program Hello;
 
begin
 
begin
Line 23: Line 23:
 
   readln
 
   readln
 
end.  
 
end.  
</delphi>
+
</syntaxhighlight>
 
{|style=color-backgroud="white" cellspacing="20"
 
{|style=color-backgroud="white" cellspacing="20"
 
|[[Compilers|previous]]   
 
|[[Compilers|previous]]   

Revision as of 15:27, 24 March 2012

български (bg) Deutsch (de) English (en) español (es) français (fr) italiano (it) 日本語 (ja) 한국어 (ko) русский (ru) svenska (sv) 中文(中国大陆)‎ (zh_CN)

Hello, World (author: Tao Yue, state: unchanged)

In the short history of computer programming, one enduring tradition is that the first program in a new language is a "Hello, world" to the screen. So let's do that. Copy and paste the program below into your IDE or text editor, then compile and run it.

If you have no idea how to do this, return to the Table of Contents. Earlier lessons explain what a compiler is, give links to downloadable compilers, and walk you through the installation of an open-source Pascal compiler on Windows.

program Hello;
begin
  writeln ('Hello, world.')
end.

The output on your screen should look like:

Hello, world.

If you're running the program in an IDE, you may see the program run in a flash, then return to the IDE before you can see what happened. See the bottom of the previous lesson for the reason why. One suggested solution, adding a readln to wait for you to press Enter before ending the program, would alter the "Hello, world" program to become:

program Hello;
begin
  writeln ('Hello, world.');
  readln
end.
previous contents next