Raise

From Lazarus wiki

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


Back to Reserved words.


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

The reserved word raise:

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