Solved

UNITS

Posted on 2000-03-09
2
169 Views
Last Modified: 2010-04-04
well.....I have a problem..as you know...If we decide tu declare a procedure,, we must declare it in the interface section and in the public section,,,,,,do I have to write something special,?....

I know that the definition of the procedure must be at the implementation section................
but it sent me teh error 108...
can you help me??
0
Comment
Question by:Iamme
[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 1

Accepted Solution

by:
AttarSoftware earned 25 total points
ID: 2601110
If a procedure is to be part of your form/component, etc then you need to declare it within the class definition.  If it is to be called by other things then it need to be in the public section, if not, the private, eg:

------------------------------

unit Unit1

interface

type
  tForm1 = class( tForm )
    private
      procedure MyFunction( param : longint ) ;
    public
  end ;

implementation

{$R *.RES}

procedure tForm1.MyFunction( param : longint ) ;
begin
  // Code here...
end ;

------------------------------

For a private procedure, and

---------------------------------

unit Unit1

interface

type
  tForm1 = class( tForm )
    private
    public
      procedure MyFunction( param : longint ) ;
  end ;

implementation

{$R *.RES}

procedure tForm1.MyFunction( param : longint ) ;
begin
  // Code here...
end ;

--------------------------------

for a public one...

If the function does not relate to a class, but you still want to call it from outside the current unit, then you do not need to put it into the class definition, but in the interface section instead, eg :

--------------------------------

unit Unit1

interface

type
  tForm1 = class( tForm )
    private
    public
  end ;

  procedure MyFunction( param : longint ) ;

implementation

{$R *.RES}

procedure MyFunction( param : longint ) ;
begin
  // Code here...
end ;

--------------------------

  (note there is no tForm1. infront of the implementation of the procedure)

And if the procedure is not required outside the current unit, then you do not have to declare it in the interface section...

Hope this helps,

Good luck,

Tim.
0
 

Author Comment

by:Iamme
ID: 2601856
ok the information that you sent me explain all about the procedures and qhere to put it ..
can you tell me your e-mail???...because I'm not the best programming and I think I'll have more problems (It's the unique form to learn)....
Thank's..
0

Featured Post

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 120
Graphics32 under Delphi 10.1 Berlin 2 180
RESTRequest Parameter 4 81
SQL Server Express automatically execute SQL or SP 8 66
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…
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 update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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