Questions tagged [delphi-units]

Delphi units are source code modules (text files with .pas extension) that are compiled individually to form an application.

Delphi units are source code modules (text files with .pas extension) that are compiled individually to form an application. They are composed of four mandatory sections: header, interface, implementation, and closure; and by another two optional sections: initialization and finalization.

Example of the syntax of a unit:

unit UnitName; // Header section (mandatory)

interface // Interface section (mandatory)    
// Used to define required other units, constants, types, global variables, methods

implementation // Implementation section (mandatory)
// Implementation of the declared procedures and functions (methods)

initialization // Initialization section (optional)
// Sentences to be executed the first time that unit is referenced

finalization // Finalization section (optional)
// Sentences to cleanup allocated memory or freeing locked resources

end. // Closure section (mandatory)
29 questions
2
votes
0 answers

How can I make the IDE aware of units used in a project which uses my package?

I'm writing a package for a custom component. This package allows the user/developer to either include numerous pre-written units in their project which are explicitly designed to work with this custom control, or write their own to do the same as…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
1
vote
1 answer

Is it safe to use only Data and System scoped units to build mutiplatform

Since XE2 the Delphi units are scoped. Unit Scope Names Unit Names Is is right to say that if I use only System and Data scoped units my code will be multiplatform and compiled for both Mac and Windows targets? and the rest of the Vcl, Winapi, and…
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
1
vote
3 answers

Circular reference issue with Classes which use each other

I have the following two classes: TcmTPDataPanel = class(TcmTPBasePanel) Database: TnxDatabase; Session: TnxSession; private FDataConnector: TcmTPDataConnector; MyNxDataBase: TnxDatabase; MyNxSession: TnxSession; …
Jamo
  • 3,238
  • 6
  • 40
  • 66
1
vote
3 answers

Delphi Unit local variables - how to make each instance unique?

In the unit below I have a variable declared in the IMPLEMENTATION section - local to the unit. I also have a procedure, declared in the TYPE section which takes an argument and assigns that argument to the local variable in question. Each instance…
J...
  • 30,968
  • 6
  • 66
  • 143
1
vote
3 answers

Accessing data stored in another unit Delphi

In Unit2 of my program i have the following code: TValue = Record NewValue, OldValue, SavedValue : Double; end; TData = Class(TObject) Public EconomicGrowth : TValue; Inflation : TValue; Unemployment : TValue; CurrentAccountPosition…
chendriksen
  • 1,026
  • 6
  • 16
  • 30
1
vote
4 answers

Uses with unit file path in unit file

I have problem. I ll try to explain it. I have a unit which has a class and may will have new functions. D3BF4E849ACC45249B990F802EFB1F15\UnitFile1.pas 8DC8977E7A7B469AACFE3CC77CA7075E\UnitFile1.pas Both of them have same class: IClass_1 = class Im…
tcak
  • 2,142
  • 1
  • 16
  • 23
1
vote
3 answers

Are units in delphi same as classes in other languages?

I need to write some Delphi code, but I have no prior experience with Delphi. I've seen people writing some code, known as unit1 or unit2 and import it using the code inside them. So, can I see the unit as a class in Java or C#?
diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
0
votes
1 answer

Having own library units in the same build config as the project

How can I setup Delphi library folders so I can have both Debug and Release versions of my units library when I work on a project ? Until now I compiled my library in Release mode once is finished. But I encountered situations when I work on a…
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
0
votes
0 answers

How to control the number of Units showing in central pane?

Recently moved to Delphi 10.4 and I get far too many Units showing in the central pane of the IDE. (It didn't happen with XE.) My main project group has up to 15 programs in it. I can remove each unit manually from view in the central pane, but if…
Mike Scott
  • 169
  • 2
  • 8
0
votes
3 answers

How to reference a unit (in runtime) if I only have its string name in Delphi?

I have types in distincts units with the same name and I have the unit name in a string. I need to access the specific type of this unit. How do I do that? Example: unit Unit1 type TFooType = ( bar1, bar2 ); then, I have another…
Haruki
  • 674
  • 1
  • 9
  • 24
0
votes
1 answer

Is it possible to use form attributes in separate unit?

I am creating a game using delphi and want to move some of my code to a separate unit, however this code uses attributes from a form. Is this possible? I am creating a game using a VCL form application and currently have all my code for the game…
Elsie.J
  • 9
  • 2
0
votes
1 answer

Acessing several units implementing a Interface with equal names

I have two or more units I need download from third party when your versions have changes. I use xml databind to generate the units. They are something as: unit tissV01; interface uses .....; type IXMLMensagemTISS = interface(IXMLNode) …
Luiz Alves
  • 2,575
  • 4
  • 34
  • 75
0
votes
1 answer

How can i CloseComm, OpenComm, WriteComm and ReadComm with the windows unit?

I have an old comm unit that uses WinTypes,WinProcs. As i understand these were merged too the Windows unit. Are there similar functions in the Windows unit?
Makaku00
  • 121
  • 5
  • 14
-1
votes
1 answer

Delphi canvas figures

i got some homework on Dephi (never used it before, only c++/java but in my universuty we've got delphi language subject). Well, i need to make form with moving figures, shown how they collides and stuff like. I started to make a uint like some…
DanilGholtsman
  • 2,354
  • 4
  • 38
  • 69
1
2