Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 04.05.2010, 20:22   #1
Lisёноk
Пользователь
 
Регистрация: 08.03.2010
Сообщений: 75
По умолчанию Ошибка

Делаю программу с вынесение процедуры в DLL-библиотеку:
Процедура в DLLке:
Код:
library find;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes;

Type TA=array of array of integer;
  var t,d:integer;
  {$R *.res}
procedure findzero (x:TA; y:integer; var found: boolean);EXPORT; STDCALL;
 var i,j:integer;

begin
 found:=false;
For i:=0 to t-1 do
begin
For j:=0 to d-1 do
begin
if (x[i,j]=0) then
 begin
found:=true;
 break;
 end;
 end;
end;
end;
EXPORTS
 findzero;

end.
А вот код программы:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    Button1: TButton;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure LabeledEdit1Change(Sender: TObject);
    procedure LabeledEdit2Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 TYPE TA=ARRAY of array of integer;
 var
  Form1: TForm1;
  a:TA; b:Ta; i, j, t, d:integer; l:boolean;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
TYPE
TProc = Procedure (x:TA; y:integer; var found: boolean); STDCALL;

CONST DLLName='find.DLL'; // èìÿ DLL

VAR
Handle:THandle;
F:TProc;

begin
  t:=StrToInt(LabeledEdit1.Text);
  d:=StrToInt(LabeledEdit2.Text);
  SetLength (a,t,d);
  SetLength (b,t,d);

  for i:=0 to t-1 do
 begin
   for j:=0 to d-1 do
  begin
     a[i,j]:=random(10);
     stringgrid1.cells[j,i]:=inttostr(a[i,j]);
  end;
 end;
  for j:=0 to d-1 do
 begin
   Handle := LoadLibrary(DLLName); // çàãðóçêà áèáëèîòåêè
   IF ( Handle <> 0 ) THEN
  BEGIN
     // ïîëó÷åíèå àäðåñà ôóíêöèè GetArea â áèáëèîòåêå
     @F:=GetProcAddress(Handle,'findzero');
     IF Assigned(F) THEN
   BEGIN
       // âûçîâ ïðîöåäóðû
       F(a,i, l);
       if l then
    begin
        for i:=0 to t-1 do
     begin
          Label1.Caption:= 'Åñòü ñòðîêè ñ íóëÿìè';
          stringgrid2.cells[j,i]:=inttostr(a[i,j])
     end;
    end
       else
     begin
          for i:=0 to t-1 do
       begin
             stringgrid2.cells[j,i]:=' ';
             Label1.Caption:= 'Íåò ñòðîê ñ íóëÿìè';

       end;
     end;
    end;
  end;
   // âûãðóçêà áèáëèîòåêè èç ïàìÿòè
   FreeLibrary(Handle)
  END;
END
  ELSE
  MessageDlg('Íå íàéäåíà áèáëèîòåêà '+DLLName,mtWarning,[mbOK],0);
end;



procedure TForm1.LabeledEdit1Change(Sender: TObject);
begin
  t:=StrToInt(labelededit1.Text);
  WITH StringGrid1 DO
  ColCount:=(t);
  Stringgrid2.colcount:=t;

  SetLength(a,t);
  SetLength(b,t);
end;


procedure TForm1.LabeledEdit2Change(Sender: TObject);
begin
  d:=StrToInt(labelededit2.Text);
  WITH StringGrid1 Do
RowCount:=(d);
Stringgrid2.rowcount:=d ;

SetLength(a,d);
SetLength(b,d);
end;
end.
И выдает следующие ошибки:
Цитата:
[Error] Unit1.pas(91): ';' expected but 'ELSE' found
[Error] Unit1.pas(93): '.' expected but ';' found
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
Просмотрела все, но не могу понять что не так. Помогите, пожалуйста!
Я самый порочный ангел и самый безгрешный демон...
Lisёноk вне форума Ответить с цитированием
Старый 05.05.2010, 11:24   #2
Z1000000
Форумчанин
 
Регистрация: 04.05.2010
Сообщений: 495
По умолчанию

Вот это :
Label1.Caption:= 'Íåò ñòðîê ñ íóëÿìè';

end;
end;
end;
end;
// âûãðóçêà áèáëèîòåêè èç ïàìÿòè
FreeLibrary(Handle)
END;
END
ELSE
MessageDlg('Íå íàéäåíà áèáëèîòåêà '+DLLName,mtWarning,[mbOK],0);
end;

надо заменить на это :
Label1.Caption:= 'Íåò ñòðîê ñ íóëÿìè';

end;
end;
end;
// âûãðóçêà áèáëèîòåêè èç ïàìÿòè
FreeLibrary(Handle)
END
ELSE
MessageDlg('Íå íàéäåíà áèáëèîòåêà '+DLLName,mtWarning,[mbOK],0);
end;
end;

вроде так.
перекомпилировать не могу из-за отсутсвия всего проекта.
Нажми на весы, поставь +
Для благодарностей : WebMoney WMR R252732729948
Z1000000 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Nero - ошибка драйвера DMA. ошибка CRC NecRoMat Софт 5 09.05.2012 01:29
Это ошибка Delphi или моя ошибка??? bloodeagle Общие вопросы Delphi 3 12.11.2009 15:26
Ошибка в статье = ошибка в рограмме. Alex Cones Общие вопросы Delphi 14 29.07.2009 18:17
Ошибка в Аfor i:=1 to SI do. Пишит что ошибка в SI Алексей_xXx Помощь студентам 2 29.05.2009 00:09
...Ошибка 101 (net::ERR_CONNECTION_RESET): Неизвестная ошибка... infrared Помощь студентам 0 16.04.2009 17:44