Raise

From Free Pascal wiki

Deutsch (de) English (en) suomi (fi)

The reserved word raise is used to explicitly throw an exception. The raise statement stops normal execution and transfers control to an exception handler.

summary briefly


example

program Example1;
uses sysutils;

function titleread(a_title:string):string;
var
  answer:string;
begin
  writeln ( a_title);
  readln(answer);

  if answer = '' then raise Exception.Create('Variable has no value');
  result := answer;
end;

var
  firstname,lastname:string;

begin
  firstname := titleread( 'Write your first name:');
  lastname := titleread( 'Write your last name:');
  writeln ('your name is ', firstname, ' ', lastname);
  readln;
end.

see also