Recent

Author Topic: using Units  (Read 2261 times)

CharlyTango

  • Jr. Member
  • **
  • Posts: 73
using Units
« on: January 27, 2016, 11:44:07 am »
Hi,

I'm just switching from Delphi to fpc/Lazarus and faced some basic obstacles.
One of the annoying things is that i do not find anything about the concept of using units with simple procedures and functions in other units.

Given should be a unit where some tools are collected (e.g. helper funktions ). In Delpi i collected those funktions in a unit where the function definitions were in the const part of the unit and the function bodies were in the implementation part.

How to manage this in fpc/lac?

Tanks in advance
CT.
Lazarus stable, Win32/64

rvk

  • Hero Member
  • *****
  • Posts: 6361
Re: using Units
« Reply #1 on: January 27, 2016, 11:50:49 am »
You can do what you described ("i collected those funktions in a unit where the function definitions were in the const part of the unit and the function bodies were in the implementation part") the EXACT same way as you did in Delphi. (Only the const-part you referring to is called the interface-part.)

(see http://wiki.freepascal.org/Unit)

Where are you getting stuck?
« Last Edit: January 27, 2016, 11:54:01 am by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 15646
  • Censorship about opinions does not belong here.
Re: using Units
« Reply #2 on: January 27, 2016, 12:48:23 pm »
Yup. FPC is hugely compatible with Delphi upto and including D2009 and higher provided in $mode delphi/delphiunicode.

Where are you stuck? Normally it just works...
If I smell bad code it usually is bad code and that includes my own code.

CharlyTango

  • Jr. Member
  • **
  • Posts: 73
Re: using Units
« Reply #3 on: January 27, 2016, 04:08:43 pm »
Thanks a lot!

The crucial hint was to declare the functions in the interface part of the unit.
Case closed.

Thank you
Lazarus stable, Win32/64

 

TinyPortal © 2005-2018