Home > Back-end >  Want to put DAT file into the Memo, but read and string array data type conversion will not, ask bos
Want to put DAT file into the Memo, but read and string array data type conversion will not, ask bos

Time:09-16

Type//custom type
TGraphRec=the packed record
DataLength: Integer;
GraphData: an array of TGraphData;
end;

For I:=0 to do DataLength - 1//read write data in the array
Write (GraphData [I], SizeOf (GraphData [I]));
end;

Procedure TForm1. Button3Click (Sender: TObject);
Var
Gd: TGraphData;
I: integer;
Path: the string;
BValue: TGraphRec;
The begin
Path:=OpenDialog1. FileName;
If OpenDialog1. Execute then
GetGraphRec (Path, BValue);
AppendGraphData (Path, BValue);
For I:=0 to length (BValue GraphData) - 1 do
The begin
Gd:=BValue GraphData [I];
//value:
//Memo2. Lines. The Add ((gd));
end;

end;

The end.

CodePudding user response:

It depends on the definition of TGraphData

CodePudding user response:

Forget to put the code,,,
Type
TGraphData=https://bbs.csdn.net/topics/packed record
Cycle: array [0.. 255] of the Integer;
Step: array [0.. 255] of the Integer;
Status: array [0.. 255] of the Word;
Voltage: array [0.. 255] of Single;
Current: array [0.. 255] of Single;
Capacity: array [0.. 255] of Single;
Energy: array [0.. 255] of Single;
Temperature: an array of 6 - [0.. 1] Word;
BTime: Integer;
end;

CodePudding user response:

The array data with IntToStr, FloatToStr into string, more interested in data, you can write a function:
Gd: function GraphDataToString (const TGraphData) : string;
Var
I: integer;
The begin
Result:=';
For I:=0 to 255 do
Result: the Result=+ IntToStr (gd) Cycle [I]) + ";
Result: the Result +=# 13 # 10;
//...
end;

CodePudding user response:

Since the data is more

CodePudding user response:

Numerical converted to string together (inttostr floattostr, string to connect) with "+"
The connect string assignment as memo. Lines. The text

CodePudding user response:

The key is what are you doing on the Memo to? Display is sure the result is bad, how far you are so many data of the roll?

CodePudding user response:

Watch your program seems to be the data show that there is no requirement, MEMO directly. The Lines. The LoadFromFile is ok

CodePudding user response:

Well, I just want to in a Memo to look at, but now the program compiled is normal, but did not realize,,,,
Var
Gd: TGraphData;//file structure custom type
I: integer;
Path: the string;
BValue: TGraphRec;//file structure custom type
The begin
Path:=OpenDialog1. FileName;
If OpenDialog1. Execute then
GetGraphRec (Path, BValue);//read the data of structural mass
AppendGraphData (Path, BValue);//write data of structural mass
For I:=0 to length (BValue GraphData) - 1 do
The begin
Gd:=BValue GraphData [I];
//value:
Memo2. Lines. The Add (GraphDataToString (gd));
end;
end;

CodePudding user response:

Didn't realize how to function? No show?

CodePudding user response:

Well, want to read the document in the memo
  • Related