Solved

Forward declaration error

Posted on 2003-11-10
2
188 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
[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 Comments
 
LVL 34

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

Industry Leaders: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 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