Solved

Forward declaration error

Posted on 2003-11-10
2
184 Views
Last Modified: 2010-04-05
Hi,

Please see the following code. I want to forward declare these 2 subroutines, whatelse I can't use them on the routines that I've in the interface part because they are not known if I don't forward declarew them. See below for more details. Thanks
function init_mail:integer;
procedure end_mail;

unit xEml;
interface
 
Function send_mail(const Para, Cc, Bcc: array of string; const subject: String; const body, Attachments: array of string): Integer;
Function send_fax(const numero, mensagem, documento: String): Integer;
 
implementation
uses Email;

---- ERROR I've to forward declare this 2 subroutines in the interface part, or whatelse I've an error in the initizialization part: 'BEGIN' expexted but 'INITIALIZATION' found. I want to declare them in the implementation part for them to be hidden for other units

function init_mail:integer;
procedure end_mail;
 
var
  email_activo : Boolean;
  Envio_Mapi : TEmail;
 
Function send_mail(const Para, Cc, Bcc: array of string; const subject: String; const body, Attachments: array of string): Integer;
var
  i: Integer;
begin
  // Inicializa o Mapi
  Result := init_mail();
  if result <> EMAIL_OK then
    exit;
end;
 
Function send_fax(const numero, mensagem, documento: String): Integer;
begin
end;
 
function init_mail:integer;
begin
end;
 
procedure end_mail;
begin
end;
 
initialization
  init_mail;
 
finalization
  end_mail;
 
end.
0
Comment
Question by:lfgmartins
2 Comments
 
LVL 33

Expert Comment

by:Slick812
ID: 9719570
I think you may need to declare the merhods as forward

function init_mail:integer; forward;
procedure end_mail; forward;
0
 
LVL 17

Accepted Solution

by:
geobul earned 500 total points
ID: 9720708
Hi,

The other option is to place their bodies as first and second routine in the implementation section (might result in other errors if they use other routines defined below them):

unit xEml;
interface
 
Function send_mail(const Para, Cc, Bcc: array of string; const subject: String; const body, Attachments: array of string): Integer;
Function send_fax(const numero, mensagem, documento: String): Integer;
 
implementation
uses Email;

var
  email_activo : Boolean;
  Envio_Mapi : TEmail;

function init_mail:integer;
begin
end;
 
procedure end_mail;
begin
end;
 
Function send_mail(const Para, Cc, Bcc: array of string; const subject: String; const body, Attachments: array of string): Integer;
var
  i: Integer;
begin
  // Inicializa o Mapi
  Result := init_mail();
  if result <> EMAIL_OK then
    exit;
end;
 
Function send_fax(const numero, mensagem, documento: String): Integer;
begin
end;
 
initialization
  init_mail;
 
finalization
  end_mail;
 
end.

Regards, Geo
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IExtractImage Delphi 14 207
Activex get website that activex running on 3 85
how to center only a line in richedit? 4 52
can't find the executable in Simulator 1 80
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…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now