风
风零落
Unregistered / Unconfirmed
GUEST, unregistred user!
请问怎么分配啊,给一段代码如下
procedure Transmit;
var
i,count:integer;
commflg:boolean;
sbuf:array of byte;
begin
commflg:=true;
count:=Length(Send);
setLength(sbuf,count);
for i:=1 to count do
begin
sbuf:=byte(Send);
if not Form1.Comm1.WriteCommData(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(2);
end;
if not commflg then
MessageDlg('发送失败!',mterror,[mbyes],0);
end;
procedure ReadData;
var
bufferointer;
BufferLength:Word;
begin
SetLength(Receive,BufferLength);
Move(Buffer^,Receive,BufferLength);
end;
Function OpenCom(Comname:shortstring):BOOL;//打开串口
begin
Comm1.StartComm;
Comm1.CommName:=Comname;
end;
Function CloseCom:BOOL;//关闭串口
begin
Comm1.StopComm;
end;
Function SetNetID(BoardID:integer;Address:integer):BOOL;//设置门禁机网络逻辑地址号
begin
bagsize:=chr($04);
s0:=start;
s1:=start;
s2:=chr($4f);
s3:=chr(Address);
s4:=bagsize;
s5:=chr(BoardID);
Send:=s0+s1+s2+s3+s4+s5;
Transmit;
ReadData;
Raddress:=r3;
r0:=copy(Receive,1,1);
r1:=copy(Receive,2,1);
r2:=copy(Receive,3,1);
r3:=copy(Receive,4,1);
bagnumber:=copy(Receive,5,2);
if r0+r1=start+start then
if r2=chr($5f) then
Result:=true
else if r2=chr($7f) then
Result:=false
end;
用pchar和shortstring用了以后,getmem写在那,怎么写????
procedure Transmit;
var
i,count:integer;
commflg:boolean;
sbuf:array of byte;
begin
commflg:=true;
count:=Length(Send);
setLength(sbuf,count);
for i:=1 to count do
begin
sbuf:=byte(Send);
if not Form1.Comm1.WriteCommData(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(2);
end;
if not commflg then
MessageDlg('发送失败!',mterror,[mbyes],0);
end;
procedure ReadData;
var
bufferointer;
BufferLength:Word;
begin
SetLength(Receive,BufferLength);
Move(Buffer^,Receive,BufferLength);
end;
Function OpenCom(Comname:shortstring):BOOL;//打开串口
begin
Comm1.StartComm;
Comm1.CommName:=Comname;
end;
Function CloseCom:BOOL;//关闭串口
begin
Comm1.StopComm;
end;
Function SetNetID(BoardID:integer;Address:integer):BOOL;//设置门禁机网络逻辑地址号
begin
bagsize:=chr($04);
s0:=start;
s1:=start;
s2:=chr($4f);
s3:=chr(Address);
s4:=bagsize;
s5:=chr(BoardID);
Send:=s0+s1+s2+s3+s4+s5;
Transmit;
ReadData;
Raddress:=r3;
r0:=copy(Receive,1,1);
r1:=copy(Receive,2,1);
r2:=copy(Receive,3,1);
r3:=copy(Receive,4,1);
bagnumber:=copy(Receive,5,2);
if r0+r1=start+start then
if r2=chr($5f) then
Result:=true
else if r2=chr($7f) then
Result:=false
end;
用pchar和shortstring用了以后,getmem写在那,怎么写????