Summary
Converts the content of the Values array of the calling vector to a list of strings.
Class
TVec
Declaration
Procedure ValuesToStrings(AList: TStrings; ListIndex, Index, Len: integer; const ReFormat: string = ' 0.#####;-0.#####'; const ImFormat: string = '+0.#####i;-0.#####i');
Description
Convert elements from Index to Index+Len-1 of the calling vector to strings with formating ReFormat for the real part and ImFormat for the imaginary part and store them in AList starting at ListIndex. If AList is not large enough, the method will use the add method of Alist object. If vector is not complex, only the ReFormat is used.
Declaration
Procedure ValuesToStrings(AList: TStrings; const ReFormat: string = ' 0.#####;-0.#####'; const ImFormat: string = '+0.#####i;-0.#####i');
Description
Converts all elements of the calling vector to strings with formating ReFormat for the real part and ImFormat for the imaginary part and stores them in AList, by using the Add method of TStringsobject. If vector is not complex only the ReFormat is used.
Note: Complex numbers are formated by default as: a+bi. You can have any formating by specifying the ReFormat and ImFormat parameters, but in order for the StringsToValues to work, the basic a+bi formating must be preserved - (chars '+' (' - ') and 'i' ).
Example 1
procedure TForm1.Button1Click(Sender: TObject);
var a,b: TVec;
begin
CreateIt(a,b);
try
a.SetIt(False,[1,2,3,4]);
a.Cos;
b.Size(a);
b.SetVal(1);
a.Add(b);
Richedit1.Clear;
Memo1.Clear;
a.ValuesToStrings(Richedit1.Lines);
b.ValuesToStrings(Richedit1.Lines);
a.ValuesToStrings(Memo1.Lines);
b.ValuesToStrings(Memo1.Lines);
Memo1.Lines.SaveToFile('C:\Test.txt');
Memo1.Lines.LoadFromFile('C:\Test.txt');
a.StringsToValues(Memo1.Lines);
finally
FreeIt(a,b);
end;
end;
| Copyright 2008 Dew Research |
http://www.dewresearch.com