Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

UNITS

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
Iamme
Asked:
Iamme
1 Solution
 
AttarSoftwareCommented:
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
 
IammeAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now