📄 unit1.pas
字号:
nowcall:=0;
maxcalldown:=0;
mincallup:=0;
targetobject:=0;
case movedrect of
1:
begin
if elelocatefloor<7 then if getnowcallup()=True then
begin moverequire:=1;lightofftarget();exit;end;
if getnowcalldown()=True then
begin moverequire:=-1;exit;end;
end;
-1:
begin
if elelocatefloor>1 then if getnowcalldown()=True then
begin moverequire:=-1;lightofftarget();exit;end;
if getnowcallup()=True then
begin moverequire:=1;exit;end;
end;
end;
end;
{---------------------------定时器eletimer-------------------------}
procedure TForm1.eletimerTimer(Sender: TObject);
begin
case movedrect of
-1:
begin
if doorready=true then
begin
if (targetfloor>mincallup) and (mincallup>0) then targetfloor:=mincallup;
if (targetfloor>maxcalldown) and (maxcalldown>0) then targetfloor:=maxcalldown;
if (targetfloor>targetobject) and (targetobject>0) then targetfloor:=targetobject;
if dooroctimer.Enabled=True then exit;
if doortimer.Enabled=True then exit;
if elemovetimer.Enabled=True then exit;
elemovedown1.font.color:=clred;
elemovedown2.font.color:=clred;
if canmove=true then waitformove();
if (elemovetimer.Enabled=True) and (elet mod 48 =0) then exit;
canmove:=True;
elelocatefloor:=elelocatefloor-1;
lighton(elelocatefloor);
elelocate1.caption:=inttostr(elelocatefloor);
elelocate2.caption:=inttostr(elelocatefloor);
if elelocatefloor>1 then
begin
if ((downarray[elelocatefloor]=true) or (targetarray[elelocatefloor]=true)) then
begin
if downarray[elelocatefloor]=true then mshowin:=True;
if targetarray[elelocatefloor]=true then mshowout:=True;
downarray[elelocatefloor]:=false;
targetarray[elelocatefloor]:=false;
downoff(elelocatefloor);
targetoff(elelocatefloor);
dooropenclose();
end;
end;
if elelocatefloor=targetfloor then
begin
if uparray[elelocatefloor]=true then mshowin:=True;
if targetarray[elelocatefloor]=true then mshowout:=True;
lightofftarget();
if elelocatefloor=1 then
begin elemovedown1.font.color:=clwindowtext;
elemovedown2.font.color:=clwindowtext; end;
uparray[elelocatefloor]:=false;
targetarray[elelocatefloor]:=false;
upoff(elelocatefloor);
targetoff(elelocatefloor);
lighton(elelocatefloor);
eletimer.enabled:=false;
dooropenclose();
end;
end;
end;
1:
begin
if doorready=true then
begin
if targetfloor<maxcalldown then targetfloor:=maxcalldown;
if targetfloor<mincallup then targetfloor:=mincallup;
if targetfloor<targetobject then targetfloor:=targetobject;
if dooroctimer.Enabled=True then exit;
if doortimer.Enabled=true then exit;
if elemovetimer.Enabled=True then exit;
elemoveup1.font.color:=clred;
elemoveup2.font.color:=clred;
if canmove=true then waitformove();
if (elemovetimer.Enabled=True) and (elet mod 48 =0) then exit;
canmove:=True;
elelocatefloor:=elelocatefloor+1;
lighton(elelocatefloor);
elelocate1.caption:=inttostr(elelocatefloor);
elelocate2.caption:=inttostr(elelocatefloor);
if elelocatefloor<7 then
begin
if ((uparray[elelocatefloor]=true) or (targetarray[elelocatefloor]=true)) then
begin
if uparray[elelocatefloor]=true then mshowin:=True;
if targetarray[elelocatefloor]=true then mshowout:=True;
uparray[elelocatefloor]:=false;
targetarray[elelocatefloor]:=false;
upoff(elelocatefloor);
targetoff(elelocatefloor);
dooropenclose();
end;
end;
if elelocatefloor=targetfloor then
begin
if downarray[elelocatefloor]=true then mshowin:=True;
if targetarray[elelocatefloor]=true then mshowout:=True;
lightofftarget();
if elelocatefloor=7 then
begin elemoveup1.font.color:=clwindowtext;
elemoveup2.font.color:=clwindowtext;end;
downarray[elelocatefloor]:=false;
targetarray[elelocatefloor]:=false;
targetoff(elelocatefloor);
downoff(elelocatefloor);
targetoff(elelocatefloor);
lighton(elelocatefloor);
eletimer.enabled:=false;
dooropenclose();
end;
end;
end;
end;
end;
{--------------------------onclick target1-------------------------}
procedure TForm1.target1Click(Sender: TObject);
begin
target1.font.color:=clred;
if elet/48=6 then
begin
targetarray[1]:=false;
target1.font.color:=clwindowtext;
end
else targetarray[1]:=true;
if movedrect=-1 then targetobject:=1;
if elemove=false then
begin
nowtarget:=1;
targetobject:=1;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target2-------------------------}
procedure TForm1.target2Click(Sender: TObject);
begin
target2.font.color:=clred;
if elet/48=5 then
begin
targetarray[2]:=false;
target2.font.color:=clwindowtext;
end
else targetarray[2]:=true;
if movedrect=-1 then
begin
if targetobject>2 then targetobject:=2;
end
else if movedrect=1 then
begin
if targetobject<2 then targetobject:=2;
end;
if elemove=false then
begin
nowtarget:=2;
targetobject:=2;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target3-------------------------}
procedure TForm1.target3Click(Sender: TObject);
begin
target3.font.color:=clred;
if elet/48=4 then
begin
targetarray[3]:=false;
target3.font.color:=clwindowtext;
end
else targetarray[3]:=true;
if movedrect=-1 then
begin
if targetobject>3 then targetobject:=3;
end;
if movedrect=1 then
begin
if targetobject<3 then targetobject:=3;
end;
if elemove=false then
begin
nowtarget:=3;
targetobject:=3;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target4-------------------------}
procedure TForm1.target4Click(Sender: TObject);
begin
target4.font.color:=clred;
if elet/48=3 then
begin
targetarray[4]:=false;
target4.font.color:=clwindowtext;
end
else targetarray[4]:=true;
if movedrect=-1 then
begin
if targetobject>4 then targetobject:=4;
end;
if movedrect=1 then
begin
if targetobject<4 then targetobject:=4;
end;
if elemove=false then
begin
nowtarget:=4;
targetobject:=4;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target5-------------------------}
procedure TForm1.target5Click(Sender: TObject);
begin
target5.font.color:=clred;
if elet/48=2 then
begin
targetarray[5]:=false;
target5.font.color:=clwindowtext;
end
else targetarray[5]:=true;
if movedrect=-1 then
begin
if targetobject>5 then targetobject:=5;
end;
if movedrect=1 then
begin
if targetobject<5 then targetobject:=5;
end;
if elemove=false then
begin
nowtarget:=5;
targetobject:=5;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target6-------------------------}
procedure TForm1.target6Click(Sender: TObject);
begin
target6.font.color:=clred;
if elet/48=1 then
begin
targetarray[6]:=false;
target6.font.color:=clwindowtext
end
else targetarray[6]:=true;
if movedrect=1 then
begin
if targetobject<6 then targetobject:=6;
end;
if movedrect=-1 then
begin
if targetobject>6 then targetobject:=6;
end;
if elemove=false then
begin
nowtarget:=6;
targetobject:=6;
eleincall(nowtarget);
end;
end;
{--------------------------onclick target7-------------------------}
procedure TForm1.target7Click(Sender: TObject);
begin
target7.font.color:=clred;
if elet/48=0 then
begin
targetarray[7]:=false;
target7.font.color:=clwindowtext;
end
else targetarray[7]:=true;
if movedrect=1 then targetobject:=7;
if elemove=false then
begin
nowtarget:=7;
targetobject:=7;
eleincall(nowtarget);
end;
end;
{--------------------------onclick eledown7-------------------------}
procedure TForm1.eledown7Click(Sender: TObject);
begin
eledown7.font.color:=clred;
downarray[7]:=true;
if movedrect=-1 then
begin
if elelocatefloor=targetfloor then maxcalldown:=7;end
else
begin if targetfloor<7 then maxcalldown:=7; end;
if elet/48=0 then
begin
downarray[7]:=false;
eledown7.font.color:=clwindowtext;
if (dooroctimer.Enabled=True) and (whichclick=1) then exit;
if waittimer.Enabled=True then exit;
mshowin:=True;
dooropenclose();
end;
if elemove=false then
begin
nowcall:=7;
maxcalldown:=7;
eleoutcall(nowcall);
end;
end;
{--------------------------onclick eledown6-------------------------}
procedure TForm1.eledown6Click(Sender: TObject);
begin
eledown6.font.color:=clred;
downarray[6]:=true;
if movedrect=-1 then
begin
if targetfloor>6 then maxcalldown:=6;
if elelocatefloor=targetfloor then
begin
if maxcalldown<6 then maxcalldown:=6;
end;
if elet/48=1 then
begin
downarray[6]:=false;
eledown6.font.color:=clwindowtext;
if (dooroctimer.Enabled=True) and (whichclick=1) then exit;
if waittimer.Enabled=True then exit;
mshowin:=True;
dooropenclose();
end;
end
else
begin
if targetfloor<6 then maxcalldown:=6;
end;
if elemove=false then
begin
nowcall:=6;
maxcalldown:=6;
eleoutcall(nowcall);
end;
end;
{--------------------------onclick eledown5-------------------------}
procedure TForm1.eledown5Click(Sender: TObject);
begin
eledown5.font.color:=clred;
downarray[5]:=true;
if movedrect=-1 then
begin
if targetfloor>5 then maxcalldown:=5;
if elelocatefloor=targetfloor then
begin
if maxcalldown<5 then maxcalldown:=5;
end;
if elet/48=2 then
begin
downarray[5]:=false;
eledown5.font.color:=clwindowtext;
if (dooroctimer.Enabled=True) and (whichclick=1) then exit;
if waittimer.Enabled=True then exit;
mshowin:=True;
dooropenclose();
end;
end
else
begin
if targetfloor<5 then maxcalldown:=5;
end;
if elemove=false then
begin
nowcall:=5;
maxcalldown:=5;
eleoutcall(nowcall);
end;
end;
{--------------------------onclick eledown4-------------------------}
procedure TForm1.eledown4Click(Sender: TObject);
begin
eledown4.font.color:=clred;
downarray[4]:=true;
if movedrect=-1 then
begin
if targetfloor>4 then maxcalldown:=4;
if elelocatefloor=targetfloor then
begin
if maxcalldown<4 then maxcalldown:=4;
end;
if elet/48=3 then
begin
downarray[4]:=false;
eledown4.font.color:=clwindowtext;
if (dooroctimer.Enabled=True) and (whichclick=1) then exit;
if waittimer.Enabled=True then exit;
mshowin:=True;
dooropenclose();
end;
end
else
begin
if targetfloor<4 then maxcalldown:=4;
end;
if elemove=false then
begin
nowcall:=4;
maxcalldown:=4;
eleoutcall(nowcall);
end;
end;
{--------------------------onclick eledown3-------------------------}
procedure TForm1.eledown3Click(Sender: TObject);
begin
eledown3.font.color:=clred;
downarray[3]:=true;
if movedrect=-1 then
begin
if targetfloor>3 then maxcalldown:=3;
if elelocatefloor=targetfloor then
begin
if maxcalldown<3 then maxcalldown:=3;
end;
if elet/48=4 then
begin
downarray[3]:=false;
eledown3.font.color:=clwindowtext;
if (dooroctimer.Enabled=True) and (whichclick=1) then exit;
if waittimer.Enabled=True then exit;
mshowin:=True;
dooropenclose();
end;
end
else
begin
if targetfloor<3 then maxcalldown:=3;
end;
if elemove=false then
begin
nowcall:=3;
maxcalldown:=3;
eleoutcall(nowcall);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -