
01.11.2013, 01:35
|
Прохожий
|
|
Регистрация: 31.10.2013
Сообщения: 3
Версия Delphi: Delphi 7
Репутация: 10
|
|
Спасибо
Спасибо. Очень помогло. Я переписал программу теперь остался один вопрос как сделать аварийную остановку.
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, XPMan, ExtCtrls;
function Inp32(PortAdr: word): byte; stdcall; external 'inpout32.dll';
function Out32(PortAdr: word; Data: byte): byte; stdcall; external 'inpout32.dll';
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Timer1: TTimer;
XPManifest1: TXPManifest;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label4: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
// procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var d0,d1,d2,d3,G,a,b,c,d:byte;
I,k:integer;
r,l:real;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Out32(888, d0+d1+d2+d3);
form1.StatusBar1.Panels[0].Text := 'Порт 888:' + inttostr(Inp32(888));
if r=1 then begin Label4.Caption:='Вправо' end;
if l=1 then begin Label4.Caption:='Вліво' end;
//Label3.Caption:=FloatToStr(G);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
r:=1;
l:=0;
k:=1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
l:=1;
r:=0;
k:=1;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
k := StrToInt(Edit1.Text);
if r=1 then
begin
a:=1;
b:=4;
C:=2;
d:=8;
end;
if l=1 then
begin
a:=8;
b:=2;
C:=4;
d:=1;
end;
G:=0;
While G < k do
begin
G:=G+1;
Out32(888, a);
sleep (1000);
Out32(888, 0);
Out32(888, b);
sleep (1000);
Out32(888, 0);
Out32(888, c);
sleep (1000);
Out32(888, 0);
Out32(888, d);
sleep (1000);
Out32(888, 0);
end;
end;
end.
|