delphi一个函数调用问题
这是我定义的一个函数functionConvertStr2Hex(str:string;varTargate:arrayofByte;varlen:integer):Bo...
这是我定义的一个函数
function ConvertStr2Hex(str:string;var Targate:array of Byte;var len:integer):Boolean;
var
i,hexdata,lowhexdata,hexdatalen:integer;
lstr,hstr:char;
begin
hexdatalen := 0;
i:=0;
len := length(str);
if len < 1 then
result := false;
while i <= len do
begin
if ((str[i] = ' ') or (str[i] = #0)) then
begin
i:=i+1;
continue;
end;
hstr := str[i];
i:=i+1;
if i = len+1 then
break;
lstr := str[i];
hexdata := ConvertHexChar(hstr);
lowhexdata := ConvertHexChar(lstr);
if((hexdata=16) or (lowhexdata=16)) then
break
else
hexdata := hexdata*16+lowhexdata;
i:=i+1;
Targate[hexdatalen]:=byte(hexdata);
// Targate[hexdatalen]:=Char(hexdata);
hexdatalen:=hexdatalen+1;
end;
len := hexdatalen;
result := TRUE;
end;
我想在接受程序中进行函数调用处理,怎么操作?procedure Tform1.Comm1ReceiveData(Sender: TObject; Buffer: PChar;
BufferLength: Word);
var
i: integer;
begin
viewstring:='' ;
move(buffer^,rbuf,bufferlength);
viewstring:=viewstring+在此处调用;
viewstring:='接收'+ viewstring;
memo2.lines.add(viewstring);
memo2.lines.add('');
end; 展开
function ConvertStr2Hex(str:string;var Targate:array of Byte;var len:integer):Boolean;
var
i,hexdata,lowhexdata,hexdatalen:integer;
lstr,hstr:char;
begin
hexdatalen := 0;
i:=0;
len := length(str);
if len < 1 then
result := false;
while i <= len do
begin
if ((str[i] = ' ') or (str[i] = #0)) then
begin
i:=i+1;
continue;
end;
hstr := str[i];
i:=i+1;
if i = len+1 then
break;
lstr := str[i];
hexdata := ConvertHexChar(hstr);
lowhexdata := ConvertHexChar(lstr);
if((hexdata=16) or (lowhexdata=16)) then
break
else
hexdata := hexdata*16+lowhexdata;
i:=i+1;
Targate[hexdatalen]:=byte(hexdata);
// Targate[hexdatalen]:=Char(hexdata);
hexdatalen:=hexdatalen+1;
end;
len := hexdatalen;
result := TRUE;
end;
我想在接受程序中进行函数调用处理,怎么操作?procedure Tform1.Comm1ReceiveData(Sender: TObject; Buffer: PChar;
BufferLength: Word);
var
i: integer;
begin
viewstring:='' ;
move(buffer^,rbuf,bufferlength);
viewstring:=viewstring+在此处调用;
viewstring:='接收'+ viewstring;
memo2.lines.add(viewstring);
memo2.lines.add('');
end; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询