Status - These basic examples should be useful for programming with Turbo Pascal and Delphi.
Other possible words - Pascal reference, Pascal syntax, Pascal cheatsheet, Pascal cheat sheet.
| notebook and paper | for programming statements | ||||
| Parts | Data | Selection | Loops | Logic | Math |
|---|---|---|---|---|---|
| program uses label const type var procedure function begin end {comment} unit interface implementation | boolean char integer real string array record set file text packed nil | if then else case of in with goto | for downto to do while repeat until | xor and not or | div mod shl shr <> < <= = >= > + - * / |
{ Example program using basic language elements of Turbo Pascal }
{ Eventually more basic language elements should be added }
program Pascal;
uses
crt;
var
A, B, i: integer;
begin
A := 100;
B := 4;
writeln(' Before Shift - A =', A, ', B =', B);
A := A shl B;
A := A shr B;
writeln(' After Shift - A =', A, ', B =', B);
for i := B downto 0 do
begin
A := A div B;
write(A, ', ');
end;
writeln;
if (A >= 0) and (B < 100) then
case A of
1: writeln(A);
2: writeln(B);
end
else
while (A > 0) or (B > 0) do
begin
writeln(A);
writeln(B);
A := A - 1;
B := B - 1;
if (A < 0) or (B < 0) then
break;
end;
for i := 1 to 80 do
write('-');
writeln;
end.
{ Code - asm inline
Object - object inherited constructor destructor
DLL - library exports }
{ standard directives }
{ absolute
assembler
external
near far export index resident interrupt
forward
public private
virtual }
Revised 29-May-1998