A Delphi unit is a separate file used to store procedures and functions. If you know what a form is, a unit is exactly the same, except it has no visual interface. So you can't put windows controls on it like buttons and edit boxes. A form has windows controls and their associated code behind them, a unit only has the code.
They are useful if you have some functions that you use often from many different forms and you only want to write them once. For example:
function LeftStr(const S : String; Index : Integer) : String;
begin
If Index <= 0
then
Result := ''
else
Result := Copy(S, 1, Index);
end;
function RightStr(const S : String; Index : Integer) : String;
begin
If Index > Length(S)
then
Result := ''
else
Result := Copy(S, Index, (Length(S)-Index+1));
end;
Then you can have your unit's name in a forms uses clause and then use the functions LeftStr and RightStr from several different forms.
Chat with our AI personalities
The Delphi programming language is currently owned by Embarcadero.
It is a questionnaire designed by a panel of experts using the Delphi method. check out: http://www.iit.edu/~it/delphi.html It is a questionnaire designed by a panel of experts using the Delphi method. check out: http://www.iit.edu/~it/delphi.html
Here is an example sentence with the word "Delphi":It was almost hard to believe that the sun god Apollo was speaking through the Oracle of Delphi as she sat there in front of me, staring at me with those clear blue eyes.
Apolla
Delphi was the Oracle of Apollo. It was there that mortals went to seek answers to their future. A young priestess sat on a tripod, inhaling fumes from the crevice that she sat by, and priests told the seeker what she had said. It was usually ambiguous, and the seeker had to figure out the meaning of it.