Jump to content
shadowrecon

Try Except Finnaly Statments --> Questions

Recommended Posts

So im trying to learn the proper use of these, because they do not throw errors and stop the script if setup properly and you can account for the errors and ifx them. problem is ive never used them a whole lot, and i was following a tut on the and below is one of the examples. How can i do the same thing that is going on in this Tut in scar? The errors that are coming up is 'On' , 'Message', 'ClassName'

 var
 number, zero : Integer;
begin
 // Try to divide an integer by zero - to raise an exception
 Try
   zero   := 0;
   number := 1 div zero;
   ShowMessage('number / zero = '+IntToStr(number));
 except
   on E : Exception do
     ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
 end;
end;

Link to comment
Share on other sites

SCAR's engine does not support "on...do":

 

[scar]var

number, zero: Integer;

begin

try

zero := 0;

number := 1 div zero;

ShowMessage('number / zero = ' + IntToStr(number));

except

ShowMessage('Error raised');

end;

end.[/scar]

 

=/ oh well, i was just curious, figured id ask the master him self! =P thanks for the response.

 

---------- Post added at 08:01 PM ---------- Previous post was at 08:00 PM ----------

 

He is trying to get the actual details of the Exception raised a la Delphi.

 

Which it sadly does not appear to support. Not widely used but can be handy in certain circumstances.

 

I think you are the only one on here that can decode my questions bixyby =p lol

 

---------- Post added 02-14-2012 at 02:30 AM ---------- Previous post was 02-13-2012 at 08:01 PM ----------

 

So just to clarify with scar, if i use a try and except statement, and it was to cause an out of bounds or some other kind of error, it would not terminate scar instead proceed to the except statement?

Link to comment
Share on other sites

The logic goes something like this:

try
 // Code goes here
except
 // If an error occurs this code gets executed
 // without crashing SCAR
finally
 // regardless of what happens this
 // *always* get executed
end;

You don't have to use all the parts.

try
 // code
except
 // error handling code
end;

or

try
 // code
finally
 // code to always get executed
end;

Doesn't work with everything. Plugins (such as smart) seem to still crash scar.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...