Sample program: |
The following short program lets you select a dataset file and displays the coordinates and the class assignments of data points in the dataset:
program DisplayDataSet;
const
PAGE = 1;
var
dset : TIlabTrnDataSet;
FName : string;
procedure ShowDataSet;
var
i,j : integer;
begin
ChartBook.Reset;
ChartBook.TabCaption[PAGE] := 'Dataset';
ChartBook.Configure
(PAGE, // page 1
false, true, false, // only the table is visible
250, 250); // default width & height
with ChartBook.Tables[PAGE] do
begin
SuppressPaint := true;
NrOfRows := dset.NDataPoints; // adjust the table size
NrOfColumns := DSet.NClasses+2;
Clear;
CommonHeader := 'Dataset: '+FName; // create headers
Header[1] := 'XPos';
Header[2] := 'yPos';
for i:=1 to NrOfColumns do
begin
Header[i+2] := DSet.ClassNames[i];
ColumnCheckMode[i+2] := cmBox;
end;
for j:=1 to NrOfRows do // fill in the data
begin
Elem[1,j] := strff(Dset.DataXPos[j],1,2);
Elem[2,j] := strff(Dset.DataYPos[j],1,2);
ElemChecked[2+DSet.DataClass[j],j] := true;
end;
FitAllColWidths (NrOfColumns, true, 4, 200, 24);
SuppressPaint := false;
end;
end;
begin // main program
FName := SelectFile (GetILabDir(idTestData), '*.tdts', 'Select a file');
if FName <> '' then
begin
dset := TIlabTrnDataSet.Create(nil);
if dset.Load(FName)
then ShowDataSet
else MessageDlg ('cannot load dataset', mtError, [mbOK]);
dset.Free;
end;
end.
|