- Linux MultiMedia Studio Computer Accessories User Manual

Mint v4 PC Programming Guide
34
MN1278 05.2001
6. This code should now run. To add an error handler, change the first parameter to setDriveEnable to –1 to
create a run time error. This will raise an EOleException error. To trap this error, modify the code as
follows.
procedure TForm1.Button1Click(Sender: TObject);
var wbEnabled : WordBool;
begin
{ Trap errors. All errors will cause program flow to jump to the except }
try
{ Read the current state of the drive enable. }
MintController1.getDriveEnable( 0, wbEnabled );
{ Write back the toggled value. }
MintController1.setDriveEnable( 0, ( wbEnabled = FALSE ));
except
{ This is called on any function in the try block failing }
On E: Exception do MessageBox ( 0, pchar(E.Message), 'Mint Interface Library Call
failed', 0 );
end;
end;
To prevent Delphi from halting program execution in the event of an exception the ‘Stop on Delphi Exceptions’
check box must be cleared. This is found in the ‘Debugger Options’ from the ‘Tools’ menu.
Figure 3-15: Delphi - Debugger Options