Var
Sbuf: an array of byte [0.. 255];
I: integer;
S1, s2, s3: string;
The begin
Sbuf [1] :=byte ($aa);//frame head
Sbuf [2] :=byte ($aa);//frame head
Sbuf [3] :=byte ($0 a); No.//command
Sbuf [4] :=byte ($90);
Sbuf [5] :=byte ($1);
Sbuf [6] :=byte ($2);
Sbuf [7] :=byte ($?) ;///
Sbuf [8] :=byte ($?) ;///
Sbuf [9] :=byte ($?) ;///
Sum1:=0;
Sum2:=0;
For I:=1 To 9 do
The begin
Sum1:=sum1 + sbuf [I];
Sum2:=sum2 Xor sbuf [I];
The end;
Sbuf [10] :=sum1 div. 256;
Sbuf [11] :=sum1 - sbuf [10] * 256;
Sbuf [12] :=byte (sum2);//////frame tail
Senddata publishes the event;//send a function called
end;
The above "?" Is user input after converting the dynamic changes of the string as s1, s2, s3, if fill in the converted specific characters, such as: dc, fb, 1 d run is no problem, but when using s1, s2, s3 replace cannot run always error, suggests that is not a valid integer, how to deal with each master??
CodePudding user response:
Sbuf [7] :=Byte (IntToStr (HexDisplayPrefix + s1));CodePudding user response:
Byte in a string variable to an error, of course, numerical characters, such as the string is converted to an integer,CodePudding user response:
Type is wrong, how can not complain,,,CodePudding user response:
Sbuf [7] :=hextoint (s1);///If there is not ready-made hextoint d7 function, need to write their own
CodePudding user response:
Sbuf [7] :=Byte (StrToInt (HexDisplayPrefix + s1));CodePudding user response:
Sbuf [7] :=byte (StrToInt (' 0 x + S1));I am using D6