LazStats: Fix crash in MatManUnit. Some simplification with file filters.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8014 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2021-05-09 12:35:11 +00:00
parent 36a67fd7a4
commit 743208b12e

View File

@ -288,31 +288,40 @@ implementation
uses
MainUnit;
{ TMatManFrm }
const
FILE_FILTERS =
'Matrix (*.mat)|*.mat;*.MAT|' +
'Column Vector (*.cve)|*.cve;*.CVE|'+
'Row Vector (*.rve)|*.rve;*.RVE|'+
'Scalar (*.scl)|*.sca;*.SCA|'+
'All (*.*)|*.*';
{ TMatManFrm }
procedure TMatManFrm.FormCreate(Sender: TObject);
begin
if ScriptEditorFrm <> nil then
if ScriptEditorFrm = nil then
Application.CreateForm(TScriptEditorFrm, ScriptEditorFrm);
if ScriptOptsFrm <> nil then
if ScriptOptsFrm = nil then
Application.CreateForm(TScriptOptsFrm, ScriptOptsFrm);
if OutputFrm <> nil then
if OutputFrm = nil then
Application.CreateForm(TOutputFrm, OutputFrm);
end;
procedure TMatManFrm.FormShow(Sender: TObject);
const
matExt = '.mat';
cvecExt = '.cve';
rvecExt = '.rve';
scaExt = '.sca';
var
count, index : integer;
filename, matext, cvecext, rvecext, scaext, extstr : string;
filename, extstr : string;
scriptopts : TextFile;
checked : integer;
begin
ResetGrids(Self);
matext := '.MAT';
cvecext := '.CVE';
rvecext := '.RVE';
scaext := '.SCA';
scripteditorfrm.FileListBox1.Directory := Options.DefaultDataPath;
scripteditorfrm.FileListBox1.Update;
count := scripteditorfrm.FileListBox1.Items.Count;
@ -326,9 +335,9 @@ begin
if extstr = rvecext then RowVecsBox.Items.Add(filename);
if extstr = scaext then ScalarsBox.Items.Add(filename);
end;
if FileExists('Options.SCR') then
if FileExists('options.scr') then
begin
AssignFile(scriptopts, 'Options.SCR');
AssignFile(scriptopts, 'options.scr');
Reset(scriptopts);
Readln(scriptopts,checked);
if checked = 1 then scriptoptsfrm.CheckGroup1.Checked[0] := true;
@ -340,19 +349,18 @@ end;
procedure TMatManFrm.Grid1Click(Sender: TObject);
begin
CurrentGrid := 1;
CurrentObjName := MatOneEdit.Text;
GridNoEdit.Text := IntToStr(1);
if ((Rows1 > 2) and (Cols1 > 2)) then CurrentObjType := 1;
if ((Rows1 > 2) and (Cols1 = 2)) then CurrentObjType := 2;
if ((Rows1 = 2) and (Cols1 > 2)) then CurrentObjType := 3;
if ((Rows1 = 2) and (Cols1 = 2)) then CurrentObjType := 4;
CurrentGrid := 1;
CurrentObjName := MatOneEdit.Text;
GridNoEdit.Text := IntToStr(1);
if ((Rows1 > 2) and (Cols1 > 2)) then CurrentObjType := 1;
if ((Rows1 > 2) and (Cols1 = 2)) then CurrentObjType := 2;
if ((Rows1 = 2) and (Cols1 > 2)) then CurrentObjType := 3;
if ((Rows1 = 2) and (Cols1 = 2)) then CurrentObjType := 4;
end;
procedure TMatManFrm.Grid1KeyPress(Sender: TObject; var Key: char);
var
instr : string;
begin
if Ord(Key) = 13 then // return pressed
begin
@ -1507,14 +1515,14 @@ end;
procedure TMatManFrm.OpenFileMnuClick(Sender: TObject);
begin
OpenDialog1.Filter := 'Matrix (*.mat)|*.MAT|Col.Vector (*.CVE)|*.CVE|RowVector (*.RVE)|*.RVE|Scaler (*.scl)|*.SCA|All (*.*)|*.*';
OpenDialog1.Filter := FILE_FILTERS;
OpenDialog1.FilterIndex := CurrentObjType;
case CurrentObjType of
1 : OpenDialog1.DefaultExt := '.MAT';
2 : OpenDialog1.DefaultExt := '.CVE';
3 : OpenDialog1.DefaultExt := '.RVE';
4 : OpenDialog1.DefaultExt := '.SCA';
else OpenDialog1.DefaultExt := '.MAT';
1 : OpenDialog1.DefaultExt := '.mat';
2 : OpenDialog1.DefaultExt := '.cve';
3 : OpenDialog1.DefaultExt := '.rve';
4 : OpenDialog1.DefaultExt := '.sca';
else OpenDialog1.DefaultExt := '.mat';
end;
GridNoEdit.Text := IntToStr(CurrentGrid);
GetGridData(CurrentGrid);
@ -3914,13 +3922,13 @@ var
BackUpName : string;
begin
SaveDialog1.Filter := 'Matrix (*.mat)|*.MAT|Col.Vector (*.CVE)|*.CVE|RowVector (*.RVE)|*.RVE|Scaler (*.scl)|*.SCA|All (*.*)|*.*';
SaveDialog1.Filter := FILE_FILTERS;
SaveDialog1.FilterIndex := CurrentObjType;
case CurrentObjType of
1 : SaveDialog1.DefaultExt := '.MAT';
2 : SaveDialog1.DefaultExt := '.CVE';
3 : SaveDialog1.DefaultExt := '.RVE';
4 : SaveDialog1.DefaultExt := '.SCA';
1 : SaveDialog1.DefaultExt := '.mat';
2 : SaveDialog1.DefaultExt := '.cve';
3 : SaveDialog1.DefaultExt := '.rve';
4 : SaveDialog1.DefaultExt := '.sca';
end;
BackUpName := ExtractFileName(CurrentObjName);
SaveDialog1.FileName := BackUpName;
@ -6586,7 +6594,7 @@ begin
end;
procedure TMatManFrm.DynMatPrint(var xmat: DynMat; rows, cols: integer;
var title: string; var ColHeadings: Dynstrarray);
var title: string; var ColHeadings: DynStrArray);
var
i, j, first, last, nflds : integer;
done : boolean;