Solved

How can I shield the systematic error message?

Posted on 2001-07-20
12
406 Views
Last Modified: 2010-04-06
Dear experts:
      Today I met with a headachy problem in my programming.I used a maskedit component,and I set its editmask "!0000/00/00" so that I can force the user to enter the right date with the format'yyyy-mm-dd'.But if the number of the numeric characters is less than 8,it would pop-up a systematic error message.Though I Used a "try ....except..",but it can' execute my customized section,i.e the except section.
      The reason I want to shield the systematic error message is that it is written in English,but I want to use another language to express it,so what shall I do?
Could you help me?Thank you very much.
0
Comment
Question by:huaqiangsheng
  • 4
  • 2
  • 2
  • +2
12 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 25 total points
Comment Utility
?

try
...
except
  showmessage(yourmessagetext);
  abort;
end;
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
or
try
...
except
  raise exception.create(Yourmessagetext);
end;
0
 

Author Comment

by:huaqiangsheng
Comment Utility
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  StdCtrls, Mask;

type
  TForm1 = class(TForm)
    MaskEdit1: TMaskEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
testdate:tdatetime;
begin
 //the edit.mask is"!0000/00/00",i.e,force the user to input 8 numbers
 try
   testdate:=strtodate(maskedit1.text);
 except
   on edbediterror do //if the format is not
                     //"!0000/00/00",e.g. "111_11_11"
   showmessag'errorinput!');//this statement is always     omitted,
                              //instead of the systematic message error"invalid input value.Use escape key to abandon changes'
   on econverterror do //if it's an invalid datetime
   showmessage('error date!');
 end;
end;

end.

My program is above mentioned,could you help me to shield the systematic error message instead of show my own error message?
  I have tried kretzschmar's method,but it doesn't work,what shall I do?
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,
If you are testing your app from Delphi IDE, it will display the system error message. Then select Run-Run from the menu to continue the execution and you will see your custom message. When you build the app and run its exe outside Delphi, you will see your custom message only.

Regards, Geo
0
 

Author Comment

by:huaqiangsheng
Comment Utility
I have tried to run my exe file outside the delphi,but it also doesn't work.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 17

Assisted Solution

by:geobul
geobul earned 25 total points
Comment Utility
Then perhaps the system is generating another error type which you don't catch in the except block. Try:

try
  testdate:=strtodate(maskedit1.text);
except
  on edbediterror do //if the format is not
                    //"!0000/00/00",e.g. "111_11_11"
  showmessage('errorinput!');//this statement is always omitted,
                             //instead of the systematic message error"invalid input value.Use escape key to abandon changes'
  on econverterror do //if it's an invalid datetime
  showmessage('error date!');
  else
    ShowMessage('The error wasn't captured !');
end;

Regards, Geo
0
 
LVL 5

Expert Comment

by:scrapdog
Comment Utility
In Debugger Options, there is a "Stop on Delphi Exceptions" checkbox that you can uncheck if you don't want to see the system messages (provided they're caught).
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,
What's going on? Did you try my last comment?

Regards, Geo
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To be PAQ/Refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi Russell,

I think that either kretzschmar's first comment or my second comment have solved the problem. Since there is no post from huaqiangsheng later on it's most likely that he got what he needed.

Regards, Geo
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility

Geo,
I would have guessed that Meikl's try...except, or your's would have solved the problem as well. I will make a note on this.

Thanks,
Russell
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now