diff --git a/applications/lazstats/LazStats.chm b/applications/lazstats/LazStats.chm index ac31b8213..316b05a02 100644 Binary files a/applications/lazstats/LazStats.chm and b/applications/lazstats/LazStats.chm differ diff --git a/applications/lazstats/README.txt b/applications/lazstats/README.txt index d4e266b9e..07b7d3af0 100644 --- a/applications/lazstats/README.txt +++ b/applications/lazstats/README.txt @@ -6,7 +6,9 @@ Clone of the LazStats statistics application by William Miller What is different? ------------------ -- Update form layout. +- Updated form layout. More consistent user interface. Use anchoring and + autosizing to avoid widgetset-dependent layout issues. +- Input validation for more robust user interface. - Move units into subfolders for each major menu command in order to avoid the extremely long file list in the project manager. - Include data and documentation folders of the original site. @@ -14,6 +16,8 @@ What is different? pdf help files. - Create chm help from the original pdf help files of the original site, tool used: HelpNDoc. +- Refactoring of code to write text output into a TStringList instead of to + the memo of TOutputFrm directly. License ------- diff --git a/applications/lazstats/data/ItemDat.laz b/applications/lazstats/data/ItemDat.laz index 019ddf313..97226cb8b 100644 --- a/applications/lazstats/data/ItemDat.laz +++ b/applications/lazstats/data/ItemDat.laz @@ -1,55 +1,55 @@ 16 8 -VAR1 +VAR1 VARIABLE 1 -4 -F -2 +1 +I +0 99999 L -VAR2 +VAR2 VARIABLE 2 -4 -F -2 +1 +I +0 99999 L -VAR3 +VAR3 VARIABLE 3 -4 -F -2 +1 +I +0 99999 L -VAR4 +VAR4 VARIABLE 4 -4 -F -2 +1 +I +0 99999 L -VAR5 +VAR5 VARIABLE 5 -4 -F -2 +1 +I +0 99999 L -LastName +LastName VARIABLE 6 7 S 0 99999 L -FirstName +FirstName VARIABLE 7 3 S 0 99999 L -IDNO +IDNO VARIABLE 8 2 I @@ -57,155 +57,155 @@ I 99999 L Case 0 -VAR1 -VAR2 -VAR3 -VAR4 -VAR5 -LastName -FirstName -IDNO -CASE 1 -1.00 -1.00 -1.00 -1.00 -1.00 +VAR1 +VAR2 +VAR3 +VAR4 +VAR5 +LastName +FirstName +IDNO +Case 1 +1 +1 +1 +1 +1 Miller Bill 1 -CASE 2 -1.00 -1.00 -1.00 -1.00 -0.00 +Case 2 +1 +1 +1 +1 +0 Benton Barb 2 -CASE 3 -1.00 -1.00 -1.00 -0.00 -0.00 +Case 3 +1 +1 +1 +0 +0 Richards Tom 3 -CASE 4 -1.00 -1.00 -0.00 -0.00 -0.00 +Case 4 +1 +1 +0 +0 +0 Thomas Keith 4 -CASE 5 -1.00 -0.00 -0.00 -0.00 -0.00 +Case 5 +1 +0 +0 +0 +0 King Bob 5 -CASE 6 -0.00 -0.00 -0.00 -0.00 -0.00 +Case 6 +0 +0 +0 +0 +0 Moreland Rob 6 -CASE 7 -1.00 -0.00 -0.00 -0.00 -0.00 +Case 7 +1 +0 +0 +0 +0 Landis Sandy 7 -CASE 8 -1.00 -1.00 -0.00 -0.00 -0.00 +Case 8 +1 +1 +0 +0 +0 Moore Vernil 8 -CASE 9 -1.00 -1.00 -1.00 -0.00 -0.00 +Case 9 +1 +1 +1 +0 +0 Tyler Dick 9 -CASE 10 -1.00 -1.00 -1.00 -1.00 -0.00 +Case 10 +1 +1 +1 +1 +0 Cook Harry 10 -CASE 11 -1.00 -1.00 -1.00 -1.00 -1.00 +Case 11 +1 +1 +1 +1 +1 Rains Claude 11 -CASE 12 -1.00 -0.00 -1.00 -0.00 -1.00 +Case 12 +1 +0 +1 +0 +1 Kent Clark 12 -CASE 13 -0.00 -1.00 -1.00 -1.00 -0.00 +Case 13 +0 +1 +1 +1 +0 Clinton Bill 13 -CASE 14 -1.00 -1.00 -1.00 -0.00 -1.00 +Case 14 +1 +1 +1 +0 +1 Bush George 14 -CASE 15 -1.00 -1.00 -0.00 -1.00 -1.00 +Case 15 +1 +1 +0 +1 +1 Jefferson Tom 15 -CASE 16 -1.00 -0.00 -0.00 -1.00 -0.00 +Case 16 +1 +0 +0 +1 +0 Lincoln Abe 16 diff --git a/applications/lazstats/data/ItemDat.tab b/applications/lazstats/data/ItemDat.tab new file mode 100644 index 000000000..4fc7df571 --- /dev/null +++ b/applications/lazstats/data/ItemDat.tab @@ -0,0 +1,17 @@ +VAR1 VAR2 VAR3 VAR4 VAR5 LastName FirstName IDNO +1 1 1 1 1 Miller Bill 1 +1 1 1 1 0 Benton Barb 2 +1 1 1 0 0 Richards Tom 3 +1 1 0 0 0 Thomas Keith 4 +1 0 0 0 0 King Bob 5 +0 0 0 0 0 Moreland Rob 6 +1 0 0 0 0 Landis Sandy 7 +1 1 0 0 0 Moore Vernil 8 +1 1 1 0 0 Tyler Dick 9 +1 1 1 1 0 Cook Harry 10 +1 1 1 1 1 Rains Claude 11 +1 0 1 0 1 Kent Clark 12 +0 1 1 1 0 Clinton Bill 13 +1 1 1 0 1 Bush George 14 +1 1 0 1 1 Jefferson Tom 15 +1 0 0 1 0 Lincoln Abe 16 diff --git a/applications/lazstats/data/itemrel.laz b/applications/lazstats/data/itemrel.laz new file mode 100644 index 000000000..61241feb8 --- /dev/null +++ b/applications/lazstats/data/itemrel.laz @@ -0,0 +1,220 @@ +17 +8 +VAR1 +VARIABLE 1 +4 +F +2 +99999 +L +VAR2 +VARIABLE 2 +4 +F +2 +99999 +L +VAR3 +VARIABLE 3 +4 +F +2 +99999 +L +VAR4 +VARIABLE 4 +4 +F +2 +99999 +L +VAR5 +VARIABLE 5 +4 +F +2 +99999 +L +VAR6 +VARIABLE 6 +4 +F +2 +99999 +L +VAR7 +VARIABLE 7 +4 +F +2 +99999 +L +VAR8 +VARIABLE 8 +4 +F +2 +99999 +L +Case 0 +VAR1 +VAR2 +VAR3 +VAR4 +VAR5 +VAR6 +VAR7 +VAR8 +Case 1 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +Case 2 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +Case 3 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +Case 4 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +Case 5 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +Case 6 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 7 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 8 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 9 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 10 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 11 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 12 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +0.00 +Case 13 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +0.00 +Case 14 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +0.00 +Case 15 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +0.00 +Case 16 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +0.00 +Case 17 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 +1.00 diff --git a/applications/lazstats/data/itemrel.tab b/applications/lazstats/data/itemrel.tab new file mode 100644 index 000000000..a2b9043d2 --- /dev/null +++ b/applications/lazstats/data/itemrel.tab @@ -0,0 +1,18 @@ +VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 +1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 +1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.00 +1.00 1.00 1.00 1.00 1.00 1.00 0.00 0.00 +1.00 1.00 1.00 1.00 1.00 0.00 0.00 0.00 +1.00 1.00 1.00 1.00 0.00 0.00 0.00 0.00 +1.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 +1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 +1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 +0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 +1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 +1.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 +1.00 1.00 1.00 0.00 0.00 0.00 0.00 0.00 +1.00 1.00 1.00 1.00 0.00 0.00 0.00 0.00 +1.00 1.00 1.00 1.00 1.00 0.00 0.00 0.00 +1.00 1.00 1.00 1.00 1.00 1.00 0.00 0.00 +1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.00 +1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 diff --git a/applications/lazstats/docs/HelpNDoc/LazStats.hnd b/applications/lazstats/docs/HelpNDoc/LazStats.hnd index 58a821b2a..b9b6c2bb7 100644 Binary files a/applications/lazstats/docs/HelpNDoc/LazStats.hnd and b/applications/lazstats/docs/HelpNDoc/LazStats.hnd differ diff --git a/applications/lazstats/source/forms/analysis/comparisons/latinsqrsunit.pas b/applications/lazstats/source/forms/analysis/comparisons/latinsqrsunit.pas index b40c43282..82f1b1dc7 100644 --- a/applications/lazstats/source/forms/analysis/comparisons/latinsqrsunit.pas +++ b/applications/lazstats/source/forms/analysis/comparisons/latinsqrsunit.pas @@ -1899,7 +1899,7 @@ var Grptotals: DblDyneVec; Subjtotals: DblDyneMat; design: StrDyneMat; - G, term1, term2, term3, term4, term5, term6, term7: double; + term1, term2, term3, term4, term5, term6, term7: double; sumxsqr: double; SSbetsubj, SSgroups, SSsubwGrps, SSwithinsubj, SSa, SSb, SSab: double; SSerrwithin, SStotal, MSgroups, MSsubwGrps, MSa, MSb, MSab: double; @@ -1994,7 +1994,6 @@ begin for j := 0 to n do Subjtotals[i,j] := 0.0; - G := 0.0; sumxsqr := 0.0; term1 := 0.0; term2 := 0.0; @@ -2398,7 +2397,7 @@ var Grptotals: DblDyneVec; Subjtotals: DblDyneMat; design: StrDyneMat; - G, term1, term2, term3, term4, term5, term6, term7: double; + term1, term2, term3, term4, term5, term6, term7: double; sumxsqr: double; SSbetsubj, SSgroups, SSsubwGrps, SSwithinsubj, SSa, SSb, SSab: double; SSerrwithin, SStotal, MSgroups, MSsubwGrps, MSa, MSb, MSab: double; @@ -2493,7 +2492,6 @@ begin for j := 0 to n do Subjtotals[i,j] := 0.0; - G := 0.0; sumxsqr := 0.0; term1 := 0.0; term2 := 0.0; @@ -2898,7 +2896,7 @@ var Grptotals: DblDyneVec; Subjtotals: DblDyneMat; design: StrDyneMat; - G, term1, term2, term3, term4, term5, term6, term7, term8, term9: double; + term1, term2, term3, term4, term5, term6, term7, term8, term9: double; sumxsqr: double; SSbetsubj, SSgroups, SSsubwGrps, SSwithinsubj, SSa, SSb, SSc, SSab: double; SSerrwithin, SStotal, MSgroups, MSsubwGrps, MSa, MSb, MSc, MSab: double; @@ -3000,7 +2998,6 @@ begin for j := 0 to n do Subjtotals[i,j] := 0.0; - G := 0.0; sumxsqr := 0.0; term1 := 0.0; term2 := 0.0; diff --git a/applications/lazstats/source/forms/analysis/cross-classification/twowayloglinunit.pas b/applications/lazstats/source/forms/analysis/cross-classification/twowayloglinunit.pas index f3de89626..2f2adcf13 100644 --- a/applications/lazstats/source/forms/analysis/cross-classification/twowayloglinunit.pas +++ b/applications/lazstats/source/forms/analysis/cross-classification/twowayloglinunit.pas @@ -249,7 +249,6 @@ end; procedure TTwoWayLogLinFrm.ComputeBtnClick(Sender: TObject); var Data : DblDyneMat; - NewData : DblDyneMat = nil; Prop : DblDyneMat; LogData : DblDyneMat; Expected : DblDyneMat; @@ -313,7 +312,6 @@ begin SetLength(Prop, Nrows + 1, Ncols + 1); SetLength(LogData, Nrows + 1, Ncols + 1); SetLength(Expected, Nrows + 1, Ncols + 1); - SetLength(NewData, Nrows + 1, Ncols + 1); SetLength(NewRowMarg, Nrows + 1); SetLength(NewColMarg, Ncols + 1); @@ -348,7 +346,6 @@ begin SetLength(Prop,Nrows+1,Ncols+1); SetLength(LogData,Nrows+1,Ncols+1); SetLength(Expected,Nrows+1,Ncols+1); - SetLength(NewData,Nrows+1,Ncols+1); SetLength(NewRowMarg,Nrows+1); SetLength(NewColMarg,Ncols+1); end; @@ -705,7 +702,6 @@ begin NewColMarg := nil; NewRowMarg := nil; - NewData := nil; Expected := nil; LogData := nil; Prop := nil; diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/matchitemunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/matchitemunit.pas index bd68289fc..27744a79f 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/matchitemunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/matchitemunit.pas @@ -206,7 +206,6 @@ end; procedure TMatchItemForm.FormShow(Sender: TObject); var - nitems: integer; noleft, noright: integer; JPEG: TJPEGImage; begin @@ -225,7 +224,6 @@ begin if ItemBankFrm.BankInfo.NMatchItems > 0 then begin - nitems := ItemBankFrm.BankInfo.NMatchItems; ItemNoEdit.Text := '1'; //IntToStr(ItemBankFrm.TFItemInfo[1].ItemNumber); MajorCodeEdit.Text := IntToStr(ItemBankFrm.MatchInfo[1].majorcode) ; MinorCodeEdit.Text := IntToStr(ItemBankFrm.MatchInfo[1].minorcode); diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/mcitemunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/mcitemunit.pas index 2b7adacb5..3c9113dcb 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/mcitemunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/item_banking/mcitemunit.pas @@ -313,7 +313,6 @@ var itemno: integer; JPEG: TJPEGImage; nochoices: integer; - response: string; begin if MessageDlg('Save current item?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then ItemSaveBtnClick(self); @@ -358,7 +357,6 @@ end; procedure TMCItemForm.StartNewBtnClick(Sender: TObject); var currentno: integer; - response: string; begin if MessageDlg('Save current item?', mtInformation, [mbYes, mbNo], 0) = mrYes then ItemSaveBtnClick(self); diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm index e4bd00243..3f97e1674 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm +++ b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.lfm @@ -1,149 +1,152 @@ object TestScoreFrm: TTestScoreFrm Left = 501 - Height = 543 + Height = 575 Top = 204 - Width = 641 + Width = 505 + HelpType = htKeyword + HelpKeyword = 'ClassicalTestAnalysis.htm' AutoSize = True Caption = 'Test Scoring and Analysis' - ClientHeight = 543 - ClientWidth = 641 + ClientHeight = 575 + ClientWidth = 505 OnActivate = FormActivate OnCreate = FormCreate OnShow = FormShow Position = poMainFormCenter LCLVersion = '2.1.0.0' - object GroupBox1: TGroupBox + object OptionsGroup: TGroupBox AnchorSideLeft.Control = Owner AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = Bevel1 Left = 8 Height = 156 - Top = 338 - Width = 625 - Anchors = [akLeft, akRight, akBottom] + Top = 370 + Width = 496 + Anchors = [akLeft, akBottom] AutoSize = True BorderSpacing.Left = 8 BorderSpacing.Top = 8 BorderSpacing.Right = 8 Caption = 'Options' - ChildSizing.LeftRightSpacing = 12 + ChildSizing.LeftRightSpacing = 16 ChildSizing.TopBottomSpacing = 6 - ChildSizing.HorizontalSpacing = 8 + ChildSizing.HorizontalSpacing = 32 ChildSizing.VerticalSpacing = 2 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 2 ClientHeight = 136 - ClientWidth = 621 + ClientWidth = 492 TabOrder = 3 object FirstChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 6 - Width = 287 + Width = 206 Caption = 'First data record is the scoring key' OnClick = FirstChkClick TabOrder = 0 end object SimultChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 6 - Width = 302 + Width = 222 Caption = 'Simultaneous Multiple Regression' TabOrder = 1 end object ReplaceChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 27 - Width = 287 + Width = 206 Caption = 'Replace grid items with item scores' TabOrder = 7 end object CorrsChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 27 - Width = 302 + Width = 222 Caption = 'Intercorrelations Matrix' TabOrder = 2 end object AddChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 48 - Width = 287 + Width = 206 Caption = 'Add Test scores to the grid' TabOrder = 8 end object PlotChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 48 - Width = 302 + Width = 222 Caption = 'Plot Total Score Distribution' TabOrder = 3 end object ListChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 69 - Width = 287 + Width = 206 Caption = 'List test scores' TabOrder = 9 end object DescChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 69 - Width = 302 + Width = 222 Caption = 'Means, Variances, Standard Deviations' TabOrder = 4 end object AlphaChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 90 - Width = 287 + Width = 206 Caption = 'Cronbach Alpha Reliability' TabOrder = 10 end object HoytChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 90 - Width = 302 + Width = 222 Caption = 'Hoyt''s Intraclass Reliability Estimates' TabOrder = 5 end object StepChk: TCheckBox - Left = 12 + Left = 16 Height = 19 Top = 111 - Width = 287 + Width = 206 Caption = 'Stepwise KR#20 Reliability' TabOrder = 11 end object MeansPlotChk: TCheckBox - Left = 307 + Left = 254 Height = 19 Top = 111 - Width = 302 + Width = 222 Caption = 'Plot Item Means' TabOrder = 6 end end - object GroupBox2: TGroupBox + object ItemScoringGroup: TGroupBox + AnchorSideLeft.Control = ObtainScoreGroup AnchorSideTop.Control = Owner AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom - Left = 411 + Left = 275 Height = 215 Top = 8 Width = 221 - Anchors = [akTop, akRight] + Anchors = [akTop, akLeft, akRight] AutoSize = True BorderSpacing.Top = 8 BorderSpacing.Right = 9 @@ -152,7 +155,7 @@ object TestScoreFrm: TTestScoreFrm ClientWidth = 217 TabOrder = 1 object Label7: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ItemNoEdit AnchorSideTop.Side = asrCenter Left = 16 @@ -164,7 +167,7 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label8: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ItemScroll AnchorSideTop.Side = asrCenter Left = 16 @@ -178,7 +181,7 @@ object TestScoreFrm: TTestScoreFrm object Label9: TLabel AnchorSideTop.Control = ItemScroll AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 194 Height = 15 @@ -190,7 +193,7 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label10: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ItemScroll AnchorSideTop.Side = asrBottom Left = 16 @@ -204,7 +207,7 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label11: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = RespNoEdit AnchorSideTop.Side = asrCenter Left = 16 @@ -216,7 +219,7 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label12: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ResponseEdit AnchorSideTop.Side = asrCenter Left = 16 @@ -228,7 +231,7 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label13: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ScoreEdit AnchorSideTop.Side = asrCenter Left = 16 @@ -240,10 +243,10 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object Label14: TLabel - AnchorSideLeft.Control = GroupBox2 + AnchorSideLeft.Control = ItemScoringGroup AnchorSideTop.Control = ResponseScroll AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 16 Height = 15 @@ -257,7 +260,7 @@ object TestScoreFrm: TTestScoreFrm object Label15: TLabel AnchorSideTop.Control = ResponseScroll AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 194 Height = 15 @@ -269,8 +272,8 @@ object TestScoreFrm: TTestScoreFrm ParentColor = False end object ItemNoEdit: TEdit - AnchorSideTop.Control = GroupBox2 - AnchorSideRight.Control = GroupBox2 + AnchorSideTop.Control = ItemScoringGroup + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 157 Height = 23 @@ -306,7 +309,7 @@ object TestScoreFrm: TTestScoreFrm object RespNoEdit: TEdit AnchorSideTop.Control = Label10 AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 157 Height = 23 @@ -320,16 +323,16 @@ object TestScoreFrm: TTestScoreFrm Text = '1' end object ResponseEdit: TEdit - AnchorSideLeft.Control = Label12 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = RespNoEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom - Left = 77 + Left = 157 Height = 23 Top = 115 - Width = 132 + Width = 52 + Alignment = taRightJustify Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 8 BorderSpacing.Top = 4 @@ -339,7 +342,7 @@ object TestScoreFrm: TTestScoreFrm object ScoreEdit: TEdit AnchorSideTop.Control = ResponseEdit AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = GroupBox2 + AnchorSideRight.Control = ItemScoringGroup AnchorSideRight.Side = asrBottom Left = 157 Height = 23 @@ -375,17 +378,19 @@ object TestScoreFrm: TTestScoreFrm OnChange = ResponseScrollChange end end - object GroupBox3: TGroupBox - AnchorSideLeft.Control = GroupBox2 - AnchorSideTop.Control = GroupBox2 + object ObtainScoreGroup: TGroupBox + AnchorSideLeft.Control = ItemScoringGroup + AnchorSideTop.Control = ItemScoringGroup AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom - Left = 411 + AnchorSideBottom.Control = Panel1 + AnchorSideBottom.Side = asrBottom + Left = 275 Height = 93 - Top = 239 + Top = 269 Width = 222 - Anchors = [akTop, akLeft, akRight] + Anchors = [akRight, akBottom] AutoSize = True BorderSpacing.Top = 16 BorderSpacing.Right = 8 @@ -403,13 +408,13 @@ object TestScoreFrm: TTestScoreFrm Top = 27 Width = 34 BorderSpacing.Left = 8 - BorderSpacing.Right = 8 + BorderSpacing.Right = 16 Caption = 'wrong' ParentColor = False end object NoCorBtn: TRadioButton - AnchorSideLeft.Control = GroupBox3 - AnchorSideTop.Control = GroupBox3 + AnchorSideLeft.Control = ObtainScoreGroup + AnchorSideTop.Control = ObtainScoreGroup Left = 12 Height = 19 Top = 4 @@ -420,7 +425,7 @@ object TestScoreFrm: TTestScoreFrm TabOrder = 0 end object FractWrongBtn: TRadioButton - AnchorSideLeft.Control = GroupBox3 + AnchorSideLeft.Control = ObtainScoreGroup AnchorSideTop.Control = NoCorBtn AnchorSideTop.Side = asrBottom Left = 12 @@ -447,7 +452,7 @@ object TestScoreFrm: TTestScoreFrm Text = '1' end object SumRespBtn: TRadioButton - AnchorSideLeft.Control = GroupBox3 + AnchorSideLeft.Control = ObtainScoreGroup AnchorSideTop.Control = FractWrongBtn AnchorSideTop.Side = asrBottom Left = 12 @@ -465,9 +470,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Control = ComputeBtn AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 432 + Left = 296 Height = 25 - Top = 510 + Top = 542 Width = 54 Anchors = [akRight, akBottom] AutoSize = True @@ -483,9 +488,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Control = CloseBtn AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 494 + Left = 358 Height = 25 - Top = 510 + Top = 542 Width = 76 Anchors = [akRight, akBottom] AutoSize = True @@ -502,9 +507,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom - Left = 578 + Left = 442 Height = 25 - Top = 510 + Top = 542 Width = 55 Anchors = [akRight, akBottom] AutoSize = True @@ -519,19 +524,19 @@ object TestScoreFrm: TTestScoreFrm object Panel1: TPanel AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner - AnchorSideRight.Control = GroupBox3 - AnchorSideBottom.Control = GroupBox1 + AnchorSideRight.Control = ObtainScoreGroup + AnchorSideBottom.Control = OptionsGroup Left = 8 - Height = 322 + Height = 354 Top = 8 - Width = 387 + Width = 259 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 8 BorderSpacing.Top = 8 - BorderSpacing.Right = 16 + BorderSpacing.Right = 8 BevelOuter = bvNone - ClientHeight = 322 - ClientWidth = 387 + ClientHeight = 354 + ClientWidth = 259 TabOrder = 0 object Label1: TLabel AnchorSideLeft.Control = Panel1 @@ -546,7 +551,7 @@ object TestScoreFrm: TTestScoreFrm object Label2: TLabel AnchorSideLeft.Control = ItemList AnchorSideTop.Control = Panel1 - Left = 215 + Left = 151 Height = 15 Top = 0 Width = 76 @@ -557,9 +562,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Control = LastNameEdit AnchorSideTop.Control = LastInBtn AnchorSideBottom.Control = LastNameEdit - Left = 215 + Left = 151 Height = 15 - Top = 172 + Top = 204 Width = 59 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 2 @@ -569,9 +574,9 @@ object TestScoreFrm: TTestScoreFrm object Label4: TLabel AnchorSideLeft.Control = FirstNameEdit AnchorSideBottom.Control = FirstNameEdit - Left = 215 + Left = 151 Height = 15 - Top = 228 + Top = 260 Width = 60 Anchors = [akLeft, akBottom] Caption = 'First Name:' @@ -580,9 +585,9 @@ object TestScoreFrm: TTestScoreFrm object Label5: TLabel AnchorSideLeft.Control = IDNoEdit AnchorSideBottom.Control = IDNoEdit - Left = 215 + Left = 151 Height = 15 - Top = 282 + Top = 314 Width = 58 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 2 @@ -597,9 +602,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideBottom.Control = Panel1 AnchorSideBottom.Side = asrBottom Left = 0 - Height = 305 + Height = 337 Top = 17 - Width = 171 + Width = 107 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Top = 2 BorderSpacing.Right = 8 @@ -612,7 +617,7 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Control = Panel1 AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = VarList - Left = 179 + Left = 115 Height = 28 Top = 17 Width = 28 @@ -627,7 +632,7 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = InBtn AnchorSideTop.Side = asrBottom - Left = 179 + Left = 115 Height = 28 Top = 49 Width = 28 @@ -642,9 +647,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Control = Panel1 AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = Label4 - Left = 179 + Left = 115 Height = 28 - Top = 184 + Top = 216 Width = 28 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 16 @@ -658,9 +663,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Control = Panel1 AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = Label5 - Left = 179 + Left = 115 Height = 28 - Top = 238 + Top = 270 Width = 28 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 16 @@ -675,9 +680,9 @@ object TestScoreFrm: TTestScoreFrm AnchorSideLeft.Side = asrCenter AnchorSideBottom.Control = Panel1 AnchorSideBottom.Side = asrBottom - Left = 179 + Left = 115 Height = 28 - Top = 294 + Top = 326 Width = 28 Anchors = [akLeft, akBottom] Images = MainDataModule.ImageList @@ -693,10 +698,10 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Control = Panel1 AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = Label3 - Left = 215 - Height = 139 + Left = 151 + Height = 171 Top = 17 - Width = 172 + Width = 108 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 8 BorderSpacing.Bottom = 16 @@ -714,10 +719,10 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = LastInBtn AnchorSideBottom.Side = asrBottom - Left = 215 + Left = 151 Height = 23 - Top = 189 - Width = 172 + Top = 221 + Width = 108 Anchors = [akLeft, akRight, akBottom] BorderSpacing.Left = 8 ReadOnly = True @@ -730,10 +735,10 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = FirstInBtn AnchorSideBottom.Side = asrBottom - Left = 215 + Left = 151 Height = 23 - Top = 243 - Width = 172 + Top = 275 + Width = 108 Anchors = [akLeft, akRight, akBottom] BorderSpacing.Left = 8 ReadOnly = True @@ -746,10 +751,10 @@ object TestScoreFrm: TTestScoreFrm AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = IDInBtn AnchorSideBottom.Side = asrBottom - Left = 215 + Left = 151 Height = 23 - Top = 299 - Width = 172 + Top = 331 + Width = 108 Anchors = [akLeft, akRight, akBottom] BorderSpacing.Left = 8 ReadOnly = True @@ -763,8 +768,8 @@ object TestScoreFrm: TTestScoreFrm AnchorSideBottom.Control = CloseBtn Left = 0 Height = 8 - Top = 494 - Width = 641 + Top = 526 + Width = 505 Anchors = [akLeft, akRight, akBottom] Shape = bsBottomLine end diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas index f7fc99e93..1a4631531 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/testscoreunit.pas @@ -1,3 +1,5 @@ +// File for testing: ItemDat.laz + unit TestScoreUnit; {$mode objfpc}{$H+} @@ -46,9 +48,9 @@ type RespNoEdit: TEdit; ItemNoEdit: TEdit; FractEdit: TEdit; - GroupBox1: TGroupBox; - GroupBox2: TGroupBox; - GroupBox3: TGroupBox; + OptionsGroup: TGroupBox; + ItemScoringGroup: TGroupBox; + ObtainScoreGroup: TGroupBox; Label10: TLabel; Label11: TLabel; Label6: TLabel; @@ -107,8 +109,8 @@ type procedure SimMR(AReport: TStrings); procedure Hoyt(AReport: TStrings); procedure StepKR(AReport: TStrings); - procedure PlotScores; - procedure PlotMeans; + function PlotScores: Boolean; + function PlotMeans: Boolean; procedure UpdateBtnStates; @@ -134,12 +136,11 @@ begin ResponseScroll.Min := 1; ItemScroll.Position := 1; ResponseScroll.Position := 1; - //InBtn.Enabled := true; - //OutBtn.Enabled := false; VarList.Items.Clear; ItemList.Items.Clear; for i := 1 to NoVariables do VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); + ItemNoEdit.Text := '1'; RespNoEdit.Text := '1'; ResponseEdit.Text := '1'; @@ -148,6 +149,7 @@ begin LastNameEdit.Text := ''; FirstNameEdit.Text := ''; IDNoEdit.Text := ''; + NoCorBtn.Checked := true; ReplaceChk.Checked := false; AddChk.Checked := false; @@ -158,11 +160,10 @@ begin PlotChk.Checked := false; DescChk.Checked := false; FirstChk.Checked := true; - GroupBox2.Visible := false; + + ItemScoringGroup.Visible := false; + MaxRespNo := 0; - //LastInBtn.Visible := true; - //FirstInBtn.Visible := true; - //IDInBtn.Visible := true; StepChk.Checked := false; HoytChk.Checked := false; MeansPlotChk.Checked := false; @@ -228,6 +229,7 @@ begin ComputeBtn.Constraints.MinWidth := w; CloseBtn.Constraints.MinWidth := w; + Panel1.Constraints.MinHeight := ItemScoringGroup.Top + ItemScoringGroup.Height + ObtainScoreGroup.Height + ObtainScoreGroup.BorderSpacing.Top - Panel1.Top; Constraints.MinWidth := Width; Constraints.MinHeight := Height; @@ -295,6 +297,7 @@ begin Responses[respno][item-1] := ResponseEdit.Text; RespWghts[respno][item-1] := StrToFloat(ScoreEdit.Text); end; + item := ItemScroll.Position; ItemNoEdit.Text := IntToStr(item); respno := 1; @@ -343,6 +346,7 @@ var i, j, col, start, count: integer; cellstring: string; lReport: TStrings; + canContinue: Boolean; begin NoItems := ItemList.Items.Count; @@ -402,7 +406,12 @@ begin end; end; - // now score the responses + + // Avoid crashing when the scrollbar has not been clicked. + if not FirstChk.checked and (MaxRespNo = 0) then + MaxRespNo := 1; + + // now score the responses ItemScores(); // place item scores in grid if elected @@ -462,13 +471,13 @@ begin // Get simultaneous multiple regressions if elected if SimultChk.Checked then SimMR(lReport); - if lReport.Count > 0 then DisplayReport(lReport); + if lReport.Count > 0 then canContinue := DisplayReport(lReport); // plot subject scores if elected - if PlotChk.Checked then PlotScores(); + if PlotChk.Checked and canContinue then canContinue := PlotScores(); // Plot item means if elected - if MeansPlotChk.Checked then PlotMeans(); + if MeansPlotChk.Checked and canContinue then PlotMeans(); finally lReport.Free; @@ -477,8 +486,7 @@ end; procedure TTestScoreFrm.FirstChkClick(Sender: TObject); begin - if FirstChk.Checked then GroupBox2.Visible := false else - GroupBox2.Visible := true; + ItemScoringGroup.Visible := not FirstChk.Checked; end; procedure TTestScoreFrm.FirstInBtnClick(Sender: TObject); @@ -508,32 +516,32 @@ begin score := 0.0; if (not GoodRecord(i,NoSelected,ColNoSelected)) then continue; count := count + 1; - for j := 1 to NoItems do + for j := 0 to NoItems-1 do begin - col := ColNoSelected[j-1]; - response := Trim(OS3MainFrm.DataGrid.Cells[col,i]); + col := ColNoSelected[j]; + response := Trim(OS3MainFrm.DataGrid.Cells[col, i]); for k := 1 to MaxRespNo do begin - if (response = Responses[k][j-1])then + if response = Responses[k, j]then begin if SumRespBtn.Checked then begin - score := score + RespWghts[k][j-1]; - Data[count-1,j-1] := RespWghts[k][j-1]; + score := score + RespWghts[k, j]; + Data[count-1, j] := RespWghts[k, j]; end; if NoCorBtn.Checked then begin score := score + 1; - Data[count-1,j-1] := 1; + Data[count-1, j] := 1; end; if FractWrongBtn.Checked then begin denom := StrToFloat(FractEdit.Text); fract := 1.0 / denom; - score := score + RespWghts[k][j-1] - (fract * RespWghts[k][j-1]); - Data[count-1,j-1] :=RespWghts[k][j-1] - (fract * RespWghts[k][j-1]); + score := score + RespWghts[k, j] - fract * RespWghts[k, j]; + Data[count-1,j] := RespWghts[k, j] - fract * RespWghts[k, j]; end; end; end; @@ -557,13 +565,13 @@ begin outline := ''; if IDNoEdit.Text <> '' then - outline := outline + 'PERSON ID NUMBER ' + outline := outline + 'PERSON ID NUMBER ' else - outline := outline + 'CASE '; + outline := outline + 'CASE '; if FirstNameEdit.Text <> '' then - outline := outline + 'FIRST NAME '; + outline := outline + 'FIRST NAME '; if LastNameEdit.Text <> '' then - outline := outline + 'LAST NAME TEST SCORE'; + outline := outline + 'LAST NAME TEST SCORE'; AReport.Add(outline); count := 0; @@ -578,28 +586,28 @@ begin begin col := IDCol; namestr := Trim(OS3MainFrm.DataGrid.Cells[col,i]); - outline := outline + Format('%16s ', [namestr]); + outline := outline + Format('%16s ', [namestr]); end else begin namestr := Trim(OS3MainFrm.DataGrid.Cells[0,i]); - outline := outline + Format('%-16s ', [namestr]); + outline := outline + Format('%-16s ', [namestr]); end; if FirstNameEdit.Text <> '' then begin col := FNameCol; namestr := Trim(OS3MainFrm.DataGrid.Cells[col,i]); - outline := outline + Format('%10s ', [namestr]); + outline := outline + Format('%10s ', [namestr]); end; if LastNameEdit.Text <> '' then begin col := LNameCol; namestr := Trim(OS3MainFrm.DataGrid.Cells[col,i]); - outline := outline + Format('%10s ', [namestr]); + outline := outline + Format('%9s ', [namestr]); end; - outline := outline + Format('%6.2f', [Data[count-1,NoItems]]); + outline := outline + Format('%7.2f', [Data[count-1,NoItems]]); AReport.Add(outline); end; @@ -706,19 +714,21 @@ begin if DescChk.Checked then begin + AReport.Add(''); title := 'Means'; DynVectorPrint(means, NoItems+1, title, ColLabels, NCases, AReport); + AReport.Add(''); title := 'Variances'; DynVectorPrint(variances, NoItems+1, title, ColLabels, NCases, AReport); + AReport.Add(''); title := 'Standard Deviations'; DynVectorPrint(stddevs, NoItems+1, title, ColLabels, NCases, AReport); end; if CorrsChk.Checked or DescChk.Checked then begin - AReport.Add(''); AReport.Add(DIVIDER); AReport.Add(''); end; @@ -768,7 +778,8 @@ begin AReport.Add('Multiple Correlation Coefficients for Each Variable'); AReport.Add(''); - AReport.Add('%10s%8s%10s%10s%12s%5s%5s', ['Variable','R','R2','F','Prob.>F','DF1','DF2']); + AReport.Add(' Variable R R2 F Prob > F DF1 DF2 '); + AReport.Add('---------- -------- -------- -------- -------- ----- -----'); df1 := NoItems - 1.0; df2 := NCases - NoItems; @@ -780,18 +791,20 @@ begin W[i] := (R2s[i] / df1) / ((1.0-R2s[i]) / df2); FProbs[i] := probf(W[i],df1,df2); valstring := Format('%10s', [ColLabels[i]]); - AReport.Add('%10s%10.3f%10.3f%10.3f%10.3f%5.0f%5.0f', [valstring,sqrt(R2s[i]),R2s[i],W[i],FProbs[i],df1,df2]); + AReport.Add('%10s %7.3f %7.3f %7.3f %7.3f %4.0f %4.0f', [valstring,sqrt(R2s[i]),R2s[i],W[i],FProbs[i],df1,df2]); + // betas for j := 0 to NoItems-1 do ProdMat[i,j] := -CorrMat[i,j] / CorrMat[j,j]; end; + AReport.Add(''); title := 'Betas in Columns'; MatPrint(ProdMat, NoItems, NoItems, title, RowLabels, ColLabels, NCases, AReport); + AReport.Add(''); AReport.Add('Standard Errors of Prediction'); AReport.Add('Variable Std.Error'); - for i := 0 to NoItems-1 do begin StdErr := (NCases-1) * Variances[i] * (1.0 / CorrMat[i,i]); @@ -803,6 +816,7 @@ begin for j := 0 to NoItems-1 do if (i <> j) then ProdMat[i,j] := ProdMat[i,j] * (StdDevs[j]/StdDevs[i]); + AReport.Add(''); title := 'Raw Regression Coefficients'; MatPrint(ProdMat, NoItems, NoItems, title, RowLabels, ColLabels, NCases,AReport); AReport.Add('Variable Constant'); @@ -887,12 +901,13 @@ begin AReport.Add('Analysis of Variance for Hoyt Reliabilities'); AReport.Add(''); - AReport.Add('SOURCE D.F. SS MS F PROB'); - AReport.Add('Subjects %3.0f %8.2f %8.2f %8.2f %8.2f', [dfcases, SSCases, MSCases, F1, prob1]); - AReport.Add('Within %3.0f %8.2f %8.2f', [dfwithin, SSWithin, MSWithin]); - AReport.Add('Items %3.0f %8.2f %8.2f %8.2f %8.2f', [dfitems, SSItems, MSItems, F2, prob2]); - AReport.Add('Error %3.0f %8.2f %8.2f', [dferror, SSerror, MSerror]); - AReport.Add('Total %3.0f %8.2f', [dftotal, TotalSS, MSTotal]); + AReport.Add('SOURCE D.F. SS MS F PROB '); + AReport.Add('-------- ------ --------- --------- -------- ---------'); + AReport.Add('Subjects %3.0f %8.2f %8.2f %8.2f %8.2f', [dfcases, SSCases, MSCases, F1, prob1]); + AReport.Add('Within %3.0f %8.2f %8.2f', [dfwithin, SSWithin, MSWithin]); + AReport.Add('Items %3.0f %8.2f %8.2f %8.2f %8.2f', [dfitems, SSItems, MSItems, F2, prob2]); + AReport.Add('Error %3.0f %8.2f %8.2f', [dferror, SSerror, MSerror]); + AReport.Add('Total %3.0f %8.2f', [dftotal, TotalSS, MSTotal]); AReport.Add(''); Hoyt1 := 1.0 - (MSWithin / MSCases); @@ -901,16 +916,16 @@ begin Hoyt3 := (MSCases - MSWithin) / (MSCases + (NoItems-1.0) * MSWithin); SEMeas1 := stddevs[NoItems] * sqrt(1.0 - Hoyt1); - AReport.Add('Hoyt Unadjusted Test Rel. for scale %s = %6.4f S.E. of Measurement = %8.3f', [ColLabels[NoItems], Hoyt1, SEMeas1]); + AReport.Add('Hoyt Unadjusted Test Rel. for scale %s: %6.4f; S.E. of Measurement: %8.3f', [ColLabels[NoItems], Hoyt1, SEMeas1]); SEMeas2 := stddevs[NoItems] * sqrt(1.0 - Hoyt2); - AReport.Add('Hoyt Adjusted Test Rel. for scale %s = %6.4f S.E. of Measurement = %8.3f', [ColLabels[NoItems], Hoyt2, SEMeas2]); + AReport.Add('Hoyt Adjusted Test Rel. for scale %s: %6.4f; S.E. of Measurement: %8.3f', [ColLabels[NoItems], Hoyt2, SEMeas2]); SEMeas3 := stddevs[NoItems] * sqrt(1.0 - Hoyt3); - AReport.Add('Hoyt Unadjusted Item Rel. for scale %s = %6.4f S.E. of Measurement = %8.3f', [ColLabels[NoItems], Hoyt3, SEMeas3]); + AReport.Add('Hoyt Unadjusted Item Rel. for scale %s: %6.4f; S.E. of Measurement: %8.3f', [ColLabels[NoItems], Hoyt3, SEMeas3]); SEMeas4 := stddevs[NoItems] * sqrt(1.0 - Hoyt4); - AReport.Add('Hoyt Adjusted Item Rel. for scale %s = %6.4f S.E. of Measurement = %8.3f', [ColLabels[NoItems], Hoyt4, SEMeas4]); + AReport.Add('Hoyt Adjusted Item Rel. for scale %s: %6.4f; S.E. of Measurement: %8.3f', [ColLabels[NoItems], Hoyt4, SEMeas4]); AReport.Add(''); AReport.Add(DIVIDER); @@ -1030,6 +1045,7 @@ begin incount := incount + 1; invalues[incount-1] := v1; end; + AReport.Add(''); until done; @@ -1048,7 +1064,7 @@ begin UpdateBtnStates; end; -procedure TTestScoreFrm.PlotScores; +function TTestScoreFrm.PlotScores: Boolean; var rowvar: DblDyneVec; totscrs: DblDyneVec; @@ -1096,7 +1112,7 @@ begin GraphFrm.WallColor := GRAPH_WALL_COLOR; GraphFrm.FloorColor := GRAPH_FLOOR_COLOR; GraphFrm.ShowBackWall := true; - GraphFrm.ShowModal; + Result := GraphFrm.ShowModal = mrOK; rowvar := nil; totscrs := nil; @@ -1104,7 +1120,7 @@ begin GraphFrm.Ypoints := nil; end; -procedure TTestScoreFrm.PlotMeans; +function TTestScoreFrm.PlotMeans: Boolean; var rowvar: DblDyneVec; i: integer; @@ -1133,7 +1149,7 @@ begin GraphFrm.WallColor := GRAPH_WALL_COLOR; GraphFrm.FloorColor := GRAPH_FLOOR_COLOR; GraphFrm.ShowBackWall := true; - GraphFrm.ShowModal; + Result := GraphFrm.ShowModal = mrOK; rowvar := nil; GraphFrm.Xpoints := nil; diff --git a/applications/lazstats/source/forms/misc/outputunit.pas b/applications/lazstats/source/forms/misc/outputunit.pas index 5afb11458..61a5f053e 100644 --- a/applications/lazstats/source/forms/misc/outputunit.pas +++ b/applications/lazstats/source/forms/misc/outputunit.pas @@ -50,7 +50,7 @@ type var OutputFrm: TOutputFrm; -procedure DisplayReport(AReport: TStrings); +function DisplayReport(AReport: TStrings): Boolean; implementation @@ -61,8 +61,9 @@ const TOP_MARGIN = 150; BOTTOM_MARGIN = 200; -procedure DisplayReport(AReport: TStrings); +function DisplayReport(AReport: TStrings): Boolean; begin + Result := false; if AReport.Count > 0 then begin if OutputFrm = nil then @@ -70,7 +71,7 @@ begin else OutputFrm.Clear; OutputFrm.AddLines(AReport); - OutputFrm.ShowModal; + Result := OutputFrm.ShowModal = mrOK; end; end; diff --git a/applications/lazstats/source/forms/tools/selectifunit.pas b/applications/lazstats/source/forms/tools/selectifunit.pas index dca757e14..0098461b9 100644 --- a/applications/lazstats/source/forms/tools/selectifunit.pas +++ b/applications/lazstats/source/forms/tools/selectifunit.pas @@ -87,10 +87,8 @@ type VAR RightCnt : integer; VAR Expression : string); - procedure GetExpression(VAR Expression : string; - VAR SubExpr : string; - VAR LeftParen : integer; - VAR RightParen : integer); + procedure GetExpression(const Expression: string; var SubExpr: string; + out LeftParen, RightParen: integer); procedure DelSubSt(VAR Expression : string; FromPos, ToPos : integer); @@ -384,46 +382,48 @@ begin end; end; -procedure TSelectIfFrm.GetExpression(var Expression: string; - var SubExpr: string; var LeftParen: integer; var RightParen: integer); - VAR i, j : integer; + +{ Search from left for first right paren. + Search back for first left paren (corresponding paren.) + Extract sub string. } +procedure TSelectIfFrm.GetExpression(const Expression: string; + var SubExpr: string; out LeftParen, RightParen: integer); +var + i, j : integer; begin - // Search from left for for first right paren. - // Search back for first left paren (corresponding paren.) - // Extract sub string. - RightParen := 0; - LeftParen := 0; - for i := 1 to Length(Expression) do + RightParen := 0; + LeftParen := 0; + for i := 1 to Length(Expression) do + begin + if Expression[i] = ')' then begin - if Expression[i] = ')' then - begin - RightParen := i; - break; - end; + RightParen := i; + break; end; + end; - for i := RightParen downto 1 do + for i := RightParen downto 1 do + begin + if Expression[i] = '(' then begin - if Expression[i] = '(' then - begin - LeftParen := i; - break; - end; + LeftParen := i; + break; end; + end; - if RightParen = 0 then // no parentheses - take whole expression - begin - SubExpr := Expression; - exit; - end; + if RightParen = 0 then // no parentheses - take whole expression + begin + SubExpr := Expression; + exit; + end; - j := 0; - for i := LeftParen to RightParen do - begin - j := j + 1; - SubExpr := SubExpr + Expression[i]; - end; - SetLength(SubExpr,j); + j := 0; + for i := LeftParen to RightParen do + begin + j := j + 1; + SubExpr := SubExpr + Expression[i]; + end; + SetLength(SubExpr,j); end; procedure TSelectIfFrm.DelSubSt(var Expression: string; FromPos, ToPos: integer diff --git a/applications/lazstats/source/units/dataprocs.pas b/applications/lazstats/source/units/dataprocs.pas index cb5858a90..35446c1e6 100644 --- a/applications/lazstats/source/units/dataprocs.pas +++ b/applications/lazstats/source/units/dataprocs.pas @@ -60,7 +60,8 @@ function StringsToInt(strcol : integer; VAR newcol : integer; prompt : boolean) implementation -uses MainUnit; +uses + Utils, MainUnit; Function GoodRecord(Row, NoVars: integer; const GridPos: IntDyneVec): boolean; var @@ -76,20 +77,18 @@ begin end; //------------------------------------------------------------------- -procedure FormatCell(Col, Row : integer); +procedure FormatCell(Col, Row: integer); var VarType : char; NoDec : integer; - Justify : char; + //Justify : char; missing : string; astr : string; - cellstr : string; - newcell : string; + cellStr : string; + newcellStr : string; X : double; Width : integer; cellsize : integer; - I: Integer; - begin if OS3MainFrm.DataGrid.Cells[Col,Row] = '' then exit; @@ -101,42 +100,27 @@ begin NoDec := StrToInt(DictionaryFrm.DictGrid.Cells[5,Col]); - astr := DictionaryFrm.DictGrid.Cells[7,Col]; - if astr <> '' then Justify := astr[1] else Justify := 'L'; - missing := DictionaryFrm.DictGrid.Cells[6,Col]; - cellstr := Trim(OS3MainFrm.DataGrid.Cells[Col,Row]); - if missing = cellstr then + cellStr := Trim(OS3MainFrm.DataGrid.Cells[Col,Row]); + if missing = cellStr then exit; + newCellStr := cellStr; if (VarType = 'F') and TryStrToFloat(cellStr, X) then - newcell := FloatToStrF(X, ffFixed, Width, NoDec) + newCellStr := FloatToStrF(X, ffFixed, Width, NoDec) else - if (VarType = 'I') and TryStrToInt(cellStr, I) then - newCell := IntToStr(I) - (* - if (VarTyp - if ((VarType = 'F') or (VarType = 'I')) then - begin - if TryStrToFloat(cellstr, X) then - newcell := FloatToStrF(X, ffFixed, Width, NoDec); - { - if IsNumeric(cellstr) then - begin - X := StrToFloat(cellstr); - newcell := FloatToStrF(X,ffFixed,Width,NoDec); -// Str(X:Width:NoDec,newcell); - end; - - } - end - *) - else - newcell := cellstr; + if (VarType = 'I') and TryStrToFloat(cellStr, X) then + newCellStr := IntToStr(trunc(X)); // now set justification cellsize := OS3MainFrm.DataGrid.ColWidths[Col]; // in pixels cellsize := cellsize div 8; + + { wp: justification should be done by the grid, not by adding spaces! + + astr := DictionaryFrm.DictGrid.Cells[7,Col]; + if astr <> '' then Justify := astr[1] else Justify := 'L'; + case Justify of 'L' : newcell := TrimLeft(newcell); 'C' : begin @@ -149,17 +133,19 @@ begin while Length(newcell) < cellsize do newcell := ' ' + newcell; end; end; - OS3MainFrm.DataGrid.Cells[Col,Row] := newcell; + } + + OS3MainFrm.DataGrid.Cells[Col,Row] := newCellStr; end; //------------------------------------------------------------------- procedure FormatGrid; var - i, j : integer; + i, j: integer; begin - for i := 1 to NoCases do - for j := 1 to NoVariables do FormatCell(j,i); + for i := 1 to NoCases do + for j := 1 to NoVariables do FormatCell(j,i); end; //------------------------------------------------------------------- @@ -1371,17 +1357,15 @@ begin end; procedure PasteIt; -VAR - astring, cellstr : string; - col, howlong, startcol : integer; - startrows :integer; - row, i, j : integer; - buf : pchar; - strarray : array[0..100000] of char; - size : integer; - achar : char; - pos : integer; - +var + astring, cellstr : string; + col, howlong, startcol : integer; + startrows :integer; + row, i, j : integer; +// buf : pchar; +// strarray : array[0..100000] of char; + achar : char; + pos : integer; begin Assert(OS3MainFrm <> nil); Assert(DictionaryFrm <> nil); @@ -1407,30 +1391,37 @@ begin end; OS3MainFrm.DataGrid.Row := startrows; OS3MainFrm.DataGrid.Col := startcol; + + { buf := strarray; size := 100000; + } // get clipboard info - if (Clipboard.HasFormat(CF_TEXT)) then astring := Clipboard.AsText + if (Clipboard.HasFormat(CF_TEXT)) then + astring := Clipboard.AsText else begin - ShowMessage('The clipboard does not contain text.'); + ErrorMsg('The clipboard does not contain text.'); exit; end; - buf := strarray; - size := 100000; - ClipBoard.GetTextBuf(buf,size); - // put buf in a string to parse - astring := buf; - howlong := Length(astring); - pos := 1; - cellstr := ''; - DictionaryFrm.DictGrid.ColCount := 8; - DictionaryFrm.DictGrid.RowCount := 2; - NoVariables := OS3MainFrm.DataGrid.ColCount - 1; - while howlong > 0 do - begin + { + buf := strarray; + size := 100000; + ClipBoard.GetTextBuf(buf,size); + // put buf in a string to parse + astring := buf; + } + + howlong := Length(astring); + pos := 1; + cellstr := ''; + DictionaryFrm.DictGrid.ColCount := 8; + DictionaryFrm.DictGrid.RowCount := 2; + NoVariables := OS3MainFrm.DataGrid.ColCount - 1; + while howlong > 0 do + begin achar := astring[pos]; if ord(achar) = 9 then // tab character - end of a grid cell value begin @@ -1478,14 +1469,13 @@ begin pos := pos + 1; howlong := howlong - 1; end; - end; - // delete extraneous row and column - OS3MainFrm.DataGrid.Col := NoVariables; -// DeleteCol; - OS3MainFrm.DataGrid.Row := NoCases+1; -// CutaRow; - OS3MainFrm.NoCasesEdit.Text := IntToStr(NoCases+1); - OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables); + end; + + // delete extraneous row and column + OS3MainFrm.DataGrid.Col := NoVariables; + OS3MainFrm.DataGrid.Row := NoCases+1; + OS3MainFrm.NoCasesEdit.Text := IntToStr(NoCases+1); + OS3MainFrm.NoVarsEdit.Text := IntToStr(NoVariables); end; procedure RowColSwap;