Solved

Help me with this complicated code

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 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