L
lwowo
Unregistered / Unconfirmed
GUEST, unregistred user!
请问:IdTelnet的DataAvailable的事件怎么触发的?
我写了一个段代码,
begin
cmd_vslr_s := 'cd /opt/wacos/server/vslr/bin;./vslragent.sh -v;';
for cmd_vslr_i := 1 to length(cmd_vslr_s)do
IdTelnetDemo.SendCh(cmd_vslr_s[cmd_vslr_i]);
IdTelnetDemo.SendCh(#13);
ValueListEditor1.Strings.Clear;
ValueListEditor1.InsertRow('VSLR',copy(Memo1.Lines.Strings[Memo1.Lines.Count - 7],8,100),true);
end;
但是测试发现,ValueListEditor1.InsertRow('VSLR',copy(Memo1.Lines.Strings[Memo1.Lines.Count - 7],8,100),true)的变化总是滞后,即:Memo1.Lines.Strings的内容仍然是这段代码生效前Memo1.Lines.Strings的值,并不是 IdTelnetDemo.SendCh(cmd_vslr_s[cmd_vslr_i])之后的?为什么啊?
BTWataAvailable的事件我引用的原来的IdTelnetDemo的,即如下:
procedure TfrmTelnetDemo.IdTelnetDemoDataAvailable(Sender: TIdTelnet;
const Buffer: String);
{This routine comes directly from the ICS TNDEMO code. Thanks to Francois Piette
It updates the memo control when we get data }
const
CR = #13;
LF = #10;
var
Start, Stop : Integer;
begin
if Memo1.Lines.Count = 0 then
Memo1.Lines.Add('');
Start := 1;
Stop := Pos(CR, Buffer);
if Stop = 0 then
Stop := Length(Buffer) + 1;//???????????????
while Start <= Length(Buffer)do
begin
Memo1.Lines.Strings[Memo1.Lines.Count - 1] :=
Memo1.Lines.Strings[Memo1.Lines.Count - 1] +
Copy(Buffer, Start, Stop - Start);
if Buffer[Stop] = CR then
begin
Memo1.Lines.Add('');
//$IFNDEF Linux
SendMessage(Memo1.Handle, WM_KEYDOWN, VK_UP, 1);
//{$ENDIF
end;
Start := Stop + 1;
if Start > Length(Buffer) then
Break;
if Buffer[Start] = LF then
Start := Start + 1;
Stop := Start;
while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer))do
Stop := Stop + 1;
end;
end;
我写了一个段代码,
begin
cmd_vslr_s := 'cd /opt/wacos/server/vslr/bin;./vslragent.sh -v;';
for cmd_vslr_i := 1 to length(cmd_vslr_s)do
IdTelnetDemo.SendCh(cmd_vslr_s[cmd_vslr_i]);
IdTelnetDemo.SendCh(#13);
ValueListEditor1.Strings.Clear;
ValueListEditor1.InsertRow('VSLR',copy(Memo1.Lines.Strings[Memo1.Lines.Count - 7],8,100),true);
end;
但是测试发现,ValueListEditor1.InsertRow('VSLR',copy(Memo1.Lines.Strings[Memo1.Lines.Count - 7],8,100),true)的变化总是滞后,即:Memo1.Lines.Strings的内容仍然是这段代码生效前Memo1.Lines.Strings的值,并不是 IdTelnetDemo.SendCh(cmd_vslr_s[cmd_vslr_i])之后的?为什么啊?
BTWataAvailable的事件我引用的原来的IdTelnetDemo的,即如下:
procedure TfrmTelnetDemo.IdTelnetDemoDataAvailable(Sender: TIdTelnet;
const Buffer: String);
{This routine comes directly from the ICS TNDEMO code. Thanks to Francois Piette
It updates the memo control when we get data }
const
CR = #13;
LF = #10;
var
Start, Stop : Integer;
begin
if Memo1.Lines.Count = 0 then
Memo1.Lines.Add('');
Start := 1;
Stop := Pos(CR, Buffer);
if Stop = 0 then
Stop := Length(Buffer) + 1;//???????????????
while Start <= Length(Buffer)do
begin
Memo1.Lines.Strings[Memo1.Lines.Count - 1] :=
Memo1.Lines.Strings[Memo1.Lines.Count - 1] +
Copy(Buffer, Start, Stop - Start);
if Buffer[Stop] = CR then
begin
Memo1.Lines.Add('');
//$IFNDEF Linux
SendMessage(Memo1.Handle, WM_KEYDOWN, VK_UP, 1);
//{$ENDIF
end;
Start := Stop + 1;
if Start > Length(Buffer) then
Break;
if Buffer[Start] = LF then
Start := Start + 1;
Stop := Start;
while (Buffer[Stop] <> CR) and (Stop <= Length(Buffer))do
Stop := Stop + 1;
end;
end;