type //自定義型別
TGraphRec=packed record
DataLength:Integer;
GraphData:array of TGraphData;
end;
for i := 0 to DataLength - 1 do //資料讀出寫入陣列中
Write(GraphData[i], SizeOf(GraphData[i]));
end;
procedure TForm1.Button3Click(Sender: TObject);
var
gd:TGraphData;
i:integer;
Path:string;
BValue:TGraphRec;
begin
Path:=OpenDialog1.FileName;
If OpenDialog1.Execute then
GetGraphRec(Path,BValue);
AppendGraphData(Path,BValue);
for i:=0 to length(BValue.GraphData)-1 do
begin
gd:=BValue.GraphData[i];
//取值:
//Memo2.Lines.Add((gd));
end;
end;
end.
uj5u.com熱心網友回復:
這要看TGraphData的定義uj5u.com熱心網友回復:
忘了貼代碼。。。
type
TGraphData=https://bbs.csdn.net/topics/packed record
Cycle:array[0..255] of Integer;
Step: array[0..255] of Integer;
Status:array[0..255] of 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:array[0..6-1] of Word;
BTime:Integer;
end;
uj5u.com熱心網友回復:
把陣列資料用IntToStr、FloatToStr轉成string就可以了,有意資料比較多,你可以寫一個函式:function GraphDataToString(const gd: TGraphData): string;
var
i: integer;
begin
Result := '';
for i := 0 to 255 do
Result := Result + IntToStr(gd.Cycle[i]) + ' ';
Result := Result + #13#10;
//...
end;
uj5u.com熱心網友回復:
由于資料比較多uj5u.com熱心網友回復:
數值轉換為字串連接起來(inttostr,floattostr,字串連接用"+"連接)把連接起來的字串賦值為memo.lines.text即可
uj5u.com熱心網友回復:
關鍵是你放到 Memo 去干什么?顯示是肯定效果不好的,你那么多的資料該滾多遠?uj5u.com熱心網友回復:
看你的程式似乎對資料顯示沒有什么要求,直接MEMO.Lines.LoadFromFile就可以了uj5u.com熱心網友回復:
嗯,我只是想先放到Memo看一下,但是現在程式編譯正常,但是功能沒實作。。。。
var
gd:TGraphData; //檔案結構體自定義型別
i:integer;
Path:string;
BValue:TGraphRec; //檔案結構體自定義型別
begin
Path:=OpenDialog1.FileName;
If OpenDialog1.Execute then
GetGraphRec(Path,BValue); //結構體讀資料方法
AppendGraphData(Path,BValue); //結構體寫資料方法
for i:=0 to length(BValue.GraphData)-1 do
begin
gd:=BValue.GraphData[i];
//取值:
Memo2.Lines.Add(GraphDataToString(gd));
end;
end;
uj5u.com熱心網友回復:
怎么功能沒實作?沒有顯示?uj5u.com熱心網友回復:
嗯,想把檔案讀到memo里轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/41253.html
標籤:VCL組件開發及應用
