?
Solved

Error handling in Delphi 1.0

Posted on 1997-10-16
5
Medium Priority
?
202 Views
Last Modified: 2010-04-04
Hi...

I am a student who is beginning to use Delphi 1.0 .
Would you pleez send me an explaination of how to and/or the specific code on :

1) While entering information into a database, if the wrong type of information is entered into a field of a specific type Delphi produces an error causing the program to stop.
An example would be, when alphanumeric data is entered into a numeric field and the record is posted, an error is produced and the program is terminated.

I need help on how to handle this error by giving the user an error message without terminating the program so that the user can go back and correct such a problem.

2) When one tries to post data into a table that is not in edit or insert mode, an error is produced and the program terminates. This is in the case where one uses a DBNAVIGATOR button.
 
How does one go about avoiding such termination by being able to provide the user with a suitable message to go back correct the situation.

If my questions are not sufficiently clear or ambigious, please provide any helpful information and coding on one goes about handling errors in Delphi 1.0.

Your attention will be highly appreciated.

Yours sincerely  
Sprawler.
0
Comment
Question by:sprawler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
mirek071497 earned 200 total points
ID: 1347777
Hi
You must use try..except  or  try..finally statements

example

var
  st : string;
  lk : integer;
begin
  st :='23a3';
  try
    { place here instruction which can fail }
    lk := StrToInt( st );
  except
    { this was called on error }
    showmessage( 'bad integer format' );
  end;
end;
0
 

Author Comment

by:sprawler
ID: 1347778
Hi.. Again mirek

I am uncertain what code would go into the areas you labelled :

{Place here instruction which could fail}
{This was called on error}

Please suggest code using an example, if possible.
Tanx for the speedy response to my question.

sprawler
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1347779
Hi

if you get exception at any code then you could place this after the "try". When the "try" starting then all exceptions jump to the code after "except".

Sorry but my english is poor so i don't understand which example you need. Do you need example with TTable ?
Mayby you don't know wher to place the try..except ? If yes then I think so you have code which make the post and you must place the try..except there.
0
 

Author Comment

by:sprawler
ID: 1347780
Hi again .....

An example of an error routine that you have used  or one that you could think up would be fine.  

Lets say that I am trying to enter data into a Table and the field requires an 8 digit number that is a primary key. Instead of typing in 8 digits,  I type in  7 digits. An error is displayed and the program terminates. how woul one program such an EXCEPTION.

Tanx
sprawler





0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1347781
Hi
sorry for the long time.

You must tell me more. Which database (DBF,Paradox ... ) and please submit your fields definition and simple code. I will try to help you.

BTW if you try use exceptions then please not in delphi because then you get always Exception from Delphi not from your proc. So compile program and run without delphi. I remember that you can set this in options, but now i don't know where.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question