Solved

Forward declaration error

Posted on 2003-11-10
2
185 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 80
SUM 2 INTEGER ARRAYS INTO 1 10 101
tvirtualstringtree freeze when load too manny images 10 63
Dev express lookupcombo 3 30
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 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