Solved

How can I shield the systematic error message?

Posted on 2001-07-20
12
410 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
ID: 6301319
?

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

Expert Comment

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

Author Comment

by:huaqiangsheng
ID: 6301510
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:geobul
ID: 6301837
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
ID: 6301876
I have tried to run my exe file outside the delphi,but it also doesn't work.
0
 
LVL 17

Assisted Solution

by:geobul
geobul earned 25 total points
ID: 6301922
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
ID: 6302014
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
ID: 6311207
Hi,
What's going on? Did you try my last comment?

Regards, Geo
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8703701
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
ID: 8717008
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
ID: 8717555

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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