Solved

Help me with this complicated code

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

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!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
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.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

623 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