Solved

Help me with this complicated code

Posted on 2003-11-12
4
607 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 500 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

Suggested Solutions

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…
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…
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…

734 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