Solved

How can I shield the systematic error message?

Posted on 2001-07-20
12
407 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run video youtube webbrowse 10 58
Working with hours 3 46
control image tags in a string ? 12 111
IdTCPClient and IdTCPServer exchanging data on desktops and not Android 11 96
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

23 Experts available now in Live!

Get 1:1 Help Now