Home > Back-end >  Questions about the MEMO controls! A great god, please give advice or comments!
Questions about the MEMO controls! A great god, please give advice or comments!

Time:09-18

I use the following code in the memo controls:

Procedure TForm1.Com m1ReceiveData (Sender: TObject; Buffer: Pointer;
BufferLength: Word);
Var
Xs: PChar;
The begin
GetLocalTime (st);
Xs:=Buffer;
If (xs='1') then
Xs:='exit 1 # oil pump choice! ';
If (xs='a') then
Xs:='option 1 # oil pump! ';
Memo1. Lines. The Add (xs + DateTimetostr (now ()));
end;

Why at run time, time will appear on the memo controls 2 times? Thank you very much!

CodePudding user response:

Look from generation, only show "exit 1 # oil pump choice! 2017/8/28 7:16:49
"At the back of the
2017/8/28 7:16:49

Inciting events code, if there is a "memo1. Lines. The Add (DateTimetostr (now ())); Code,
"

CodePudding user response:

Agree with the upstairs, and other events should be the add statements

CodePudding user response:

No other event!

CodePudding user response:

1, search all memo1. Lines. The Add fields, and see if it is where the trigger event,
2, track it yourself variable, which is a look at this time variable assignment,

CodePudding user response:

Receives the data processing of the COM you have any question, you only for visible characters' 1 'and' a 'to do the processing, is likely to be COM equipment also returned to the other content,
So your code in the xs:=Buffer, such processing is incomplete,
 
Procedure TForm1.Com m1ReceiveData (Sender: TObject; Buffer: Pointer;
BufferLength: Word);
Var
S: a string;
I: Word;
P, pData: PByte;
The begin
GetLocalTime (st);
S:=';
GetMem (pData, BufferLength);
Move (Buffer ^ and PByte (pData) ^, BufferLength);
P:=pData;
i:=0;
S:=';
While iThe begin
S:=s + UpperCase (IntToHex (p ^ 2));
Inc (p);
Inc (I);
end;
Memo1. Lines. The Add (s + DateTimetostr (now ()));//return to receive a hexadecimal format data
end;

CodePudding user response:

Ok, I try!
  • Related