Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help me with this complicated code

Posted on 2003-11-12
4
Medium Priority
?
609 Views
Last Modified: 2007-12-19
1---------------------------------------------------------------------
{ Test whether MAPI is available - if not, raise an exception }
 
procedure TEmail.CheckMapi;
{$IFDEF RESSTRING}
resourcestring
{$ELSE}
const
{$ENDIF RESSTRING}
  SNoMapi = 'MAPI services are not available on this system';
begin
  if not MapiAvailable then { call function in SMAPI.PAS }
    raise EMapiUnavailable.Create(SNoMapi);
end;

2---------------------------------------------------------
procedure TEmail.DoMapiError(ErrorCode: Integer);
begin
  if Assigned(FOnMapiError) then
    FOnMapiError(Self, ErrorCode);
end;

if MapiResult <> SUCCESS_SUCCESS then
      DoMapiError(MapiResult);

Thanks, Luis
0
Comment
Question by:lfgmartins
[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
  • 2
4 Comments
 
LVL 4

Expert Comment

by:kabix
ID: 9735730
What exactly the problem is?
0
 
LVL 2

Expert Comment

by:cero
ID: 9735732
hi Luis,

what's the question??

0
 

Author Comment

by:lfgmartins
ID: 9735876
Sry, what I want is if you please comment the code because I don't understand these lines of code.

- resourcestring
- raise EMapiUnavailable.Create(SNoMapi);
- FOnMapiError(Self, ErrorCode);
- DoMapiError(MapiResult);

Thanks,
Luis
0
 
LVL 2

Accepted Solution

by:
cero earned 1500 total points
ID: 9736071
well, the first part

-resourcestring

{$IFDEF RESSTRING}
resourcestring
{$ELSE}
const
{$ENDIF RESSTRING}
  SNoMapi = 'MAPI services are not available on this system';

if a compilation constant RESSTRING is defined, SNoMapi is declared as resourcestring, and if it's not the case is a const.

note apart, resourcestring replaces LoadStr(), Delphi 3 introduced the possiblity to easily place constant strings as a resource with the new keyword 'resourcestring'.

-raise

The Raise keyword creates an exception object that is passed to the Delphi exception handler.

raise EMapiUnavailable.Create(SNoMapi);
creates/raises a exception, the exception object is the result of calling EMapiUnavailable.Create(SNoMapi) so this last call create an objetc.

- FOnMapiError(Self, ErrorCode);

FOnMapiError is a event error (an object), it is a member of TMapiControl, the exact type is TMapiErrEvent.
The arguments passed to the constructor of this object are "Self" and "ErrorCode", so I guess this object requires to be constructed two arguments, an object and a error code to raise and event informing an error. In some part of the code, this exception needs to be catched.

so the procedure TEmail.CheckMapi, check for a variable (boolean I guess) and if its not available, raise an exception with the text defined in SNoMapi

- DoMapiError(MapiResult);
Is a procedure whose only one functionality is to generate a event error (FOnMapiError)

regards

cero

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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