Solved

Error handling in Delphi 1.0

Posted on 1997-10-16
5
200 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 50 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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