1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
// tests for code folding
// multi line comments
{
line1
line2
}
// begin .. end
begin
some commands
end;
record test
var1: type1;
var2: type2;
end; //record
//asm
asm
some statement
end; //asm
//try (from https://wiki.freepascal.org/Try)
try
// code that might generate an exception
except
// will only be executed in case of an exception
on E: EDatabaseError do
ShowMessage( 'Database error: '+ E.ClassName + #13#10 + E.Message );
on E: Exception do
ShowMessage( 'Error: '+ E.ClassName + #13#10 + E.Message );
end;
//try nested (from https://wiki.freepascal.org/Try)
try
try
// code dealing with database that might generate an exception
except
// will only be executed in case of an exception
on E: EDatabaseError do
ShowMessage( 'Database error: '+ E.ClassName + #13#10 + E.Message );
on E: Exception do
ShowMessage( 'Error: '+ E.ClassName + #13#10 + E.Message );
end;
finally
// clean up database-related resources
end;
//case
case x of
1: do something;
2: do some other thing;
else
do default;
end; //case
//if then else
if x=y then
do something;
else
do some other thing;
//for loop
for i:=1 to 10 do
writeln(i)
//do until
repeat
write(a);
i:=i+1;
until i>10;
//preprocessor if, else, endif
{$DEFINE label}
{$IFDEF label}
command 1
{$ELSE}
command 2
{$ENDIF}
|