Solved

Forward declaration error

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

16 Experts available now in Live!

Get 1:1 Help Now