// Effectus auto-generated Mad Pascal source code listing
program procsPrg;

uses
  Crt, StringUtils, SySutils, CIO;

var
  strBuffer : string;
var
  eff_loop_var : byte;
  eff_cnt : byte;
  eff_string : string;
// Effectus example:
// Using local PROCedures
var
  m1 : word;  // m1_byte_array
  m2 : word;  // m2_byte_array
  key : byte;  // key_byte_array

procedure PRINTTEXTProc;
begin
  Write('', eol, 'Hello from PROC', eol, '', eol, '');
end;

procedure ShowNumProc(n : byte);
begin
  eff_string := '';
  Write('Entered number is ');  // Print 1

  eff_string := '';
  Write(n);  // Print 2
  Writeln;
  if  n<>20  then begin
  eff_string := '';
  Write('It is not 20!');  // Print 1
  Writeln;
  end;  // if
end;

// Calculate the sum of two 8-bit
// numbers and print the result to the
// screen
procedure SumBytesProc(n1 : byte; n2 : byte);
var
  total1 : byte;  // total1_byte_array
begin
  total1 := n1+n2;
  eff_string := '';
  Write('Result: ');  // Print 1

  eff_string := '';
  Write(total1);  // Print 2
  Writeln;
end;

// Calculate the sum of two 16-bit
// numbers and print the result to the
// screen
procedure SumCardsProc(c1 : word; c2 : word);
var
  total2 : word;  // total2_byte_array
begin
  total2 := c1+c2;
  eff_string := '';
  Write('Result: ');  // Print 1

  eff_string := '';
  Write(total2);  // Print 2
  Writeln;
end;

// Currently, mixed data types are not supported
procedure NumbersProc(e1 : word; e2 : word; e3 : byte; e4 : integer; e5 : integer);
begin
  Write('', eol, 'e1=', e1, ',e2=', e2, '');
  Write('', eol, 'e3=', e3, '');
  Write('', eol, 'e4=', e4, ',e5=', e5, '', eol, '');
end;

procedure MAINProc;
begin
  Write(Chr(125));
  eff_string := '';
  Write('Effectus example:');  // Print 1
  Writeln;
  eff_string := '';
  Write('Using local PROCedures');  // Print 1
  Writeln;
  PRINTTEXTProc;
  eff_string := '';
  Write('Variable n holds value ');  // Print 1

  SHOWNUMProc(21);
  Writeln('');
  eff_string := '';
  Write('Input parameters: 10 and 240');  // Print 1
  Writeln;
  SUMBYTESProc(10, 240);
  Writeln('');
  m1 := 2100;
  m2 := 62000;
  eff_string := '';
  Write('Input parameters: ');  // Print 1

  eff_string := '';
  Write(m1);  // Print 2

  eff_string := '';
  Write(' and ');  // Print 1

  eff_string := '';
  Write(m2);  // Print 2
  Writeln;
  eff_string := '';
  Write('held in variables m1 and m2');  // Print 1
  Writeln;
  SUMCARDSProc(m1, m2);
  NUMBERSProc(10000, 65200, 201, 32000, 4651);
  key := Get(7);
  ReadKey;
end;

begin
  MAINProc;
end.
