Back to manual index

:: if and then [[begin end]]

:: About = format as "if then [[begin end]]"

:: Example #1:
program iftest;

var catsname : string;
    howmany : integer;
    lastname : string;

begin

  catsname := 'tishy';
  howmany := 1;
  lastname : 'Johnson';

  if catsname = 'tishy' then 
    writeln('that is my cat!');
  if howmany = 1 then 
    writeln('that is right, only one.');
  if catsname ! 'tabby' then
    writeln('wrong!');

  (* this will be true *)
  if lastname $ 'John' then
    writeln('He is a John');

  (* this will be false *)
  if lastname $ 'cow' then
    writeln('He is a cow');

end.

::Condition parameters :
=  is equal
!  is not equal
<> is not equal
$  is contains sub value (subset)
>  is greater than
<  is less than
<= is less than equal to value
>= is greater than equal to value



:: Example #2:
program MoreTestIfs;

var TestInt : integer;

begin
  
  TestInt := 5;

  if TestInt = 5 then
    begin
      writeln('Test line 1 true');
      writeln('Test line 2 true');
      writeln('Test line 3 true');
      writeln('Test line 4 ture');
      writeln('Last writeln before "end;"');
    end;

  if TestInt = 6 then
    begin
      writeln('Test line 1 False, not true and ignored');
      writeln('Test line 2 false, not true and ignored');
      writeln('Test line 3 false, not true and ignored');
      writeln('Test line 4 false, not ture again');
    end;

end.