用 StringList 更方便:
var
list: TStringList;
i, n: Integer;
Buffer: string;
begin
Buffer := 'D2 BB FA D5 CA BA C5 31 30 00 00 12 00 00 00';
list := TStringList.Create;
ExtractStrings([' '], [], PChar(Buffer), list)
// 分割
for i := 0 to list.Count - 1 do
begin
n := StrToIntDef('$' + list, 0)
// 赋给整数
ShowMessage(IntToStr);
end;
list.Free;
end;
var
list: TStringList;
i, n: Integer;
Buffer: string;
begin
Buffer := 'D2 BB FA D5 CA BA C5 31 30 00 00 12 00 00 00';
list := TStringList.Create;
ExtractStrings([' '], [], PChar(Buffer), list)
// 分割
for i := 0 to list.Count - 1 do
begin
n := StrToIntDef('$' + list, 0)
// 赋给整数
ShowMessage(IntToStr);
end;
list.Free;
end;