Solved

How can I shield the systematic error message?

Posted on 2001-07-20
12
412 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
[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
  • 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

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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