Raise

From Lazarus wiki
Revision as of 08:38, 27 April 2019 by Djzepi (talk | contribs) (Created page with "{{Raise}} The reserved word <syntaxhighlight lang="pascal" enclose="none">raise</syntaxhighlight> is used to explicitly throw an exception. T...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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.