From fd0dd2bac713911ff6401056b184a8aadd4f4db2 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 13 Apr 2020 20:57:36 +0000 Subject: [PATCH] LazStats: Simple input validation of "Brown-Forsythe test for homogeneity of variance" in MainUnit. Avoid ultra-wide input box dialogs. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7379 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../lazstats/source/forms/mainunit.pas | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas index 096fefd34..c8601e918 100644 --- a/applications/lazstats/source/forms/mainunit.pas +++ b/applications/lazstats/source/forms/mainunit.pas @@ -1252,6 +1252,9 @@ end; } procedure TOS3MainFrm.FormCreate(Sender: TObject); begin + // Reduce ultra-wide width of Inputbox windows + cInputQueryEditSizePercents := 0; + if DictionaryFrm = nil then Application.CreateForm(TDictionaryFrm, DictionaryFrm); @@ -1651,15 +1654,31 @@ end; // Menu "Analyses" > "Brown-Forsythe test for homogeneity of variance" procedure TOS3MainFrm.homotestClick(Sender: TObject); Var - response : string; - GroupCol, VarColumn,NoCases : integer; + response: string; + GroupCol, VarCol, NoCases: integer; begin - response := InputBox('Column no. of group codes:','Column?','1'); - GroupCol := StrToInt(response); - response := InputBox('Column no. of dependent variable:','Column','2'); - VarColumn := StrToInt(response); + response := '1'; + repeat + if not InputQuery('Column of group codes', 'Column index', response) then + exit; + if TryStrToInt(response, GroupCol) and (GroupCol > 0) then + break + else + MessageDlg('Illegal value entered for index of group column.', mtError, [mbOk], 0); + until false; + + response := '2'; + repeat + if not InputQuery('Column of dependent variable', 'Column index', response) then + exit; + if TryStrToInt(response, VarCol) then + break + else + MessageDlg('Illegal value entered for index of variable column.', mtError, [mbOK], 0); + until false; + NoCases := StrToInt(NoCasesEdit.text); - HomogeneityTest(GroupCol, VarColumn, NoCases); + HomogeneityTest(GroupCol, VarCol, NoCases); end; // Menu "Simulations" > "Hypergeometric probability"