蚂
蚂蚁根
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟刚学不久,遇到了很棘手的问题,用SPCOMM做串口监控,分解接收数据保存到字符串数组里,有几个错误一直困扰我,请大家帮帮忙
声明部分
private
{ Private declarations }
procedure viver(const S:string)
//procedure viver(Sender: TObject);
var
S:STRING;
procedure TFrmMain.Comm1ReceiveData(Sender: TObject
Buffer: Pointer
//接受下位机数据
BufferLength: Word);
//var
//pStrChar;
begin
if cbrevhex.Checked then
begin
pStr:= Buffer;
memo1.text:=memo1.Text+StrToHexStr(pStr);
end;
pStr:= Buffer;
s:= pstr;//这里把pstr转成s:string型,供procedure viver()调用
memo1.text:=memo1.Text+(pstr);
end;
procedure viver(const S:string);//procedure viver(Sender: TObject);
var
sp,i,j: integer;
strarr: array[1..8]of string;
begin
j:=1;
sp := pos('',s);
s := COPY(s,(sp+1),length(s)-sp);
repeat
for i=1 to length(s) do//这里说我不能用全局变量s来循环,请问我该怎么做把其他过程的值调用过来?
begin
if copy(s,i,1)<>'' then
begin
s := copy(s,i,length(s)-i);
continue;
end;
end;
sp:= pos('',s);
if i>8 then
s := ''
else
begin
strarr[j] := copy(s,1,sp-1);
inc(j);
s := copy(s,sp+1,length(s)-sp);
end;
until length(s)=0;
end;
错误:
[Error] Unit1.pas(287): Left side cannot be assigned to
[Error] Unit1.pas(293): Left side cannot be assigned to
[Error] Unit1.pas(299): Left side cannot be assigned to
[Error] Unit1.pas(304): Left side cannot be assigned to
另外还有一个困惑的问题:
当写成procedure viver(Sender: TObject);时
错误为:
[Hint] Unit1.pas(79): Private symbol 'viver' declared but never used
[Error] Unit1.pas(79): Unsatisfied forward or external declaration: 'TFrmMain.viver'
请问到底哪种声明是正确的???
for i=1 to length(s) do//这里说我不能用全局变量s来循环,请问我该怎么做把其他过程的值调用过来?
s:=string;声明成了全局变量
pchar是串口接受的数据,转换成s:string 这样不行吗?
为什么会报错Left side cannot be assigned to
???
实在不会改了,大家帮帮忙
声明部分
private
{ Private declarations }
procedure viver(const S:string)
//procedure viver(Sender: TObject);
var
S:STRING;
procedure TFrmMain.Comm1ReceiveData(Sender: TObject
Buffer: Pointer
//接受下位机数据
BufferLength: Word);
//var
//pStrChar;
begin
if cbrevhex.Checked then
begin
pStr:= Buffer;
memo1.text:=memo1.Text+StrToHexStr(pStr);
end;
pStr:= Buffer;
s:= pstr;//这里把pstr转成s:string型,供procedure viver()调用
memo1.text:=memo1.Text+(pstr);
end;
procedure viver(const S:string);//procedure viver(Sender: TObject);
var
sp,i,j: integer;
strarr: array[1..8]of string;
begin
j:=1;
sp := pos('',s);
s := COPY(s,(sp+1),length(s)-sp);
repeat
for i=1 to length(s) do//这里说我不能用全局变量s来循环,请问我该怎么做把其他过程的值调用过来?
begin
if copy(s,i,1)<>'' then
begin
s := copy(s,i,length(s)-i);
continue;
end;
end;
sp:= pos('',s);
if i>8 then
s := ''
else
begin
strarr[j] := copy(s,1,sp-1);
inc(j);
s := copy(s,sp+1,length(s)-sp);
end;
until length(s)=0;
end;
错误:
[Error] Unit1.pas(287): Left side cannot be assigned to
[Error] Unit1.pas(293): Left side cannot be assigned to
[Error] Unit1.pas(299): Left side cannot be assigned to
[Error] Unit1.pas(304): Left side cannot be assigned to
另外还有一个困惑的问题:
当写成procedure viver(Sender: TObject);时
错误为:
[Hint] Unit1.pas(79): Private symbol 'viver' declared but never used
[Error] Unit1.pas(79): Unsatisfied forward or external declaration: 'TFrmMain.viver'
请问到底哪种声明是正确的???
for i=1 to length(s) do//这里说我不能用全局变量s来循环,请问我该怎么做把其他过程的值调用过来?
s:=string;声明成了全局变量
pchar是串口接受的数据,转换成s:string 这样不行吗?
为什么会报错Left side cannot be assigned to
???
实在不会改了,大家帮帮忙