Solved

How can I shield the systematic error message?

Posted on 2001-07-20
12
411 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
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!

 
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

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

Suggested Solutions

Title # Comments Views Activity
Press three keys together and trigger a function 3 75
Create a path if not exists 7 124
tvirtualstringtree freeze when load too manny images 10 90
DBGrid or StringGrid ? 6 135
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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