![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Вызов процедуры/функции из другого Unit [D7, 2000]
vigo_ © (2006-07-18 10:09:00)Добрый день,
написал несколько своих процедур и функций, которые без проблем используются в Unit1. Теперь хочу использовать эти процедуры, функции из другого Unit'а, в uses Unit2 указал Unit1, но они по прежднему недоступны. Как сделать корректно?
vigo_ (2006-07-18 11:02:00) [1]
> Ega23 © (18.07.06 10:47) [8]
Спасибо
Ega23 (2006-07-18 10:47:00) [2]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
function MyFunctnion:Integer;
var
Form1: TForm1;
implementation
function MyFunctnion:Integer;
begin
Result;=0;
end;
{$R *.dfm}
end.
clickmaker (2006-07-18 10:44:00) [3]
> function MyFunctnion:Integer;
декларации только после uses.
В общем случае любой юнит выглядит так:
unit UnitName;
interface
uses ...
type
// типы, классы
внешние (доступные другим юнитам, которые uses этот) декларации
implementation
uses ...
приватные декларации
vigo_ (2006-07-18 10:39:00) [4]
unit Unit1;
interface
function MyFunctnion:Integer;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function MyFunctnion:Integer;
begin
Result;=0;
end;
{$R *.dfm}
end.
Ega23 (2006-07-18 10:29:00) [5]код в студию.
DrPass (2006-07-18 10:28:00) [6]
> [2] взял за образец
Значит, плохо взял. uses пиши после слова interface, а не перед :)
vigo_ (2006-07-18 10:27:00) [7]Не компилится, [2] взял за образец:
Declaration expected but 'Uses' found
Ega23 (2006-07-18 10:15:00) [8]
unit Unit1;
interface
function MyFunctnion:Integer;
implementation
function MyFunctnion:Integer;
begin
Result;=0;
end;
Ega23 (2006-07-18 10:14:00) [9]указать их в interface Unit1