Example: |
The following code snippet creates a small matrix, fills it with a constant value of 8.762813 und fills the custom data with five items called "KEY-1" to "KEY-5". The exported ASC file is shown below.
const
NCUSTDATA = 5;
PRECISION = 3;
MATNCOL = 3;
MATNROW = 6;
var
row : integer;
InMat : TMatrix;
CustData : TStr2DArray;
begin
InMat := TMatrix.CReate(nil);
InMat.Resize (MATNCOL,MATNROW);
InMat.Fill (8.762813);
SetLength (CustData, 2, NCUSTDATA);
for row:=1 to NCUSTDATA do
begin
CustData[0,row-1] := 'KEY-'+IntToStr(row);
CustData[1,row-1] := 'Value of key '+IntToStr(row);
end;
Inmat.ExportAsAsc('c:\temp\testexpo.asc', PRECISION, 'my special comment', Custdata);
InMat.free;
end;
The generated ASC file looks like this (see the ASC format specification for details):
my special comment
3 ;nr. of columns
6 ;nr. of rows
FALSE FALSE FALSE FALSE ;row attributes, column names, row names, nominal variables
8.763 8.763 8.763
8.763 8.763 8.763
8.763 8.763 8.763
8.763 8.763 8.763
8.763 8.763 8.763
8.763 8.763 8.763
<CUSTDATA>
<KEY-1>Value of key 1</KEY-1>
<KEY-2>Value of key 2</KEY-2>
<KEY-3>Value of key 3</KEY-3>
<KEY-4>Value of key 4</KEY-4>
<KEY-5>Value of key 5</KEY-5>
</CUSTDATA>
|