diff --git a/applications/lazstats/LazStats.hlp b/applications/lazstats/LazStats.hlp index 9fc1c5101..e8d895ed1 100644 --- a/applications/lazstats/LazStats.hlp +++ b/applications/lazstats/LazStats.hlp @@ -15,7 +15,7 @@ correlation, means, standard deviations and confidence interval for each correla 111=NOTE: No. of left hand variables must be less than or equal to the number of right hand variables. 112=Directions: Click on the variable that represents the measurement. Click on the Sigma button to change the default value. Click the Compute button to obtain the results. 113=Directions: Two to k variables representing dichotomous (0,1) values are analyzed for N cases. The values of the variables reflect repeated observations on the same subjects or on matched subjects. Click the variables on the left to analyze and enter them by clicking the right arrow button. -114=Directions: Forst select the test scores from the available variables. You will see a default reliability and weight ssigned to each score selected in list boxes to the right. If you click on either a reliability or a weight, an input box will appear in which you can enter a new reliability or weight. Note - you can use the KR#21 reliability program to estimate reliability if you know the maximum score. +114=Directions: First select the test scores from the available variables. You will see a default reliability and weight ssigned to each score selected in list boxes to the right. If you click on either a reliability or a weight, an input box will appear in which you can enter a new reliability or weight. Note - you can use the KR#21 reliability program to estimate reliability if you know the maximum score. 115=Directions: A Judge's ratings or observations are recorded as variables (columns) 1 through k. Each line conrresponds to a different judge (person making the rating.) Select the variables from the left list to analyze and click on the right arrow button to enter them. To remove a variable from the list of selected ones, click on the variable name in the selected list and click the left arrow button. Click the Compute button to obtain the results. 116=Directions: Select each categorical variable from the available variables in the leftmost box in the order that you wish to have the breakdown proceed. Click the OK button to start the analysis. 117=Directions: First, click on the variable name that represents the sample lot number. Next, click on the variable that represents the measurement. Click on the Delta size and enter the desired value. Click on the alpha and/or beta probability boxes and enter values to change from the default values. You may also enter target specifications if you first click the check box to use a target specification. diff --git a/applications/lazstats/source/LazStats.lpi b/applications/lazstats/source/LazStats.lpi index 63612aeef..4c8099190 100644 --- a/applications/lazstats/source/LazStats.lpi +++ b/applications/lazstats/source/LazStats.lpi @@ -661,7 +661,7 @@ - + diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.lfm b/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.lfm index 4c57e0fa0..1f4d1ad50 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.lfm +++ b/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.lfm @@ -1,317 +1,255 @@ -object CompRelFrm: TCompRelFrm +inherited CompRelForm: TCompRelForm Left = 506 Height = 361 Top = 429 - Width = 583 + Width = 802 HelpType = htKeyword HelpKeyword = 'html/WeightedCompositeReliability.htm' - AutoSize = True Caption = 'Composite Test Reliability' ClientHeight = 361 - ClientWidth = 583 - OnActivate = FormActivate - OnCreate = FormCreate - OnResize = FormResize - OnShow = FormShow - Position = poMainFormCenter - LCLVersion = '2.0.10.0' - object Label3: TLabel - AnchorSideLeft.Control = RelList - AnchorSideTop.Control = Owner - Left = 308 - Height = 15 - Top = 8 - Width = 74 - BorderSpacing.Top = 8 - Caption = 'Test Reliability' - ParentColor = False - end - object Label4: TLabel - AnchorSideLeft.Control = WeightList - AnchorSideTop.Control = Owner - Left = 460 - Height = 15 - Top = 8 - Width = 66 - BorderSpacing.Top = 8 - Caption = 'Test Weights' - ParentColor = False - end - object RelList: TListBox - AnchorSideLeft.Control = ItemList - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Label3 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = WeightList - AnchorSideBottom.Side = asrBottom - Left = 308 - Height = 228 - Top = 25 - Width = 144 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - ItemHeight = 0 - OnClick = RelListClick - TabOrder = 5 - end - object WeightList: TListBox - AnchorSideTop.Control = Label4 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Side = asrBottom - Left = 460 - Height = 228 - Top = 25 - Width = 115 - Anchors = [akTop, akRight, akBottom] - BorderSpacing.Top = 2 - BorderSpacing.Right = 8 - ItemHeight = 0 - OnClick = WeightListClick - TabOrder = 6 - end - object GroupBox1: TGroupBox - AnchorSideLeft.Control = Owner - AnchorSideBottom.Control = ButtonBevel - Left = 8 - Height = 51 - Top = 261 - Width = 387 - Anchors = [akLeft, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - Caption = 'Options' - ChildSizing.LeftRightSpacing = 12 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.HorizontalSpacing = 24 - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 2 - ClientHeight = 31 - ClientWidth = 383 - TabOrder = 7 - object RMatChk: TCheckBox - Left = 12 - Height = 19 - Top = 6 - Width = 166 - Caption = 'Print Intercorrelation Matrix' + ClientWidth = 802 + inherited ParamsPanel: TPanel + Height = 345 + Width = 424 + ClientHeight = 345 + ClientWidth = 424 + inherited CloseBtn: TButton + Left = 369 + Top = 320 + TabOrder = 11 + end + inherited ComputeBtn: TButton + Left = 285 + Top = 320 + TabOrder = 10 + end + inherited ResetBtn: TButton + Left = 223 + Top = 320 + TabOrder = 9 + end + inherited HelpBtn: TButton + Tag = 114 + Left = 164 + Top = 320 + TabOrder = 8 + end + inherited ButtonBevel: TBevel + Top = 304 + Width = 424 + end + object GroupBox1: TGroupBox[5] + AnchorSideLeft.Control = ParamsPanel + AnchorSideBottom.Control = ButtonBevel + Left = 0 + Height = 51 + Top = 253 + Width = 387 + Anchors = [akLeft, akBottom] + AutoSize = True + Caption = 'Options' + ChildSizing.LeftRightSpacing = 12 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 24 + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + ClientHeight = 31 + ClientWidth = 383 + TabOrder = 7 + object RMatChk: TCheckBox + Left = 12 + Height = 19 + Top = 6 + Width = 166 + Caption = 'Print Intercorrelation Matrix' + TabOrder = 0 + end + object GridScrChk: TCheckBox + Left = 202 + Height = 19 + Top = 6 + Width = 169 + Caption = 'Put Composite Score in Grid' + TabOrder = 1 + end + end + object Label3: TLabel[6] + AnchorSideLeft.Control = RelList + AnchorSideTop.Control = ParamsPanel + Left = 256 + Height = 15 + Top = 0 + Width = 74 + Caption = 'Test Reliability' + ParentColor = False + end + object Label4: TLabel[7] + AnchorSideLeft.Control = WeightList + AnchorSideTop.Control = ParamsPanel + Left = 344 + Height = 15 + Top = 0 + Width = 66 + Caption = 'Test Weights' + ParentColor = False + end + object RelList: TListBox[8] + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label3 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = WeightList + AnchorSideBottom.Control = VarList + AnchorSideBottom.Side = asrBottom + Left = 256 + Height = 228 + Top = 17 + Width = 80 + Anchors = [akTop, akRight, akBottom] + BorderSpacing.Left = 8 + BorderSpacing.Top = 2 + BorderSpacing.Right = 8 + ItemHeight = 0 + OnClick = RelListClick + TabOrder = 5 + end + object WeightList: TListBox[9] + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label4 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = ParamsPanel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = VarList + AnchorSideBottom.Side = asrBottom + Left = 344 + Height = 228 + Top = 17 + Width = 80 + Anchors = [akTop, akRight, akBottom] + BorderSpacing.Top = 2 + ItemHeight = 0 + OnClick = WeightListClick + TabOrder = 6 + end + object Label1: TLabel[10] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = ParamsPanel + Left = 0 + Height = 15 + Top = 0 + Width = 97 + Caption = 'Variables Available' + ParentColor = False + end + object Label2: TLabel[11] + AnchorSideLeft.Control = ItemList + AnchorSideTop.Control = ParamsPanel + Left = 150 + Height = 15 + Top = 0 + Width = 76 + Caption = 'Selected Items' + ParentColor = False + end + object VarList: TListBox[12] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = Label1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = AllBtn + AnchorSideBottom.Control = GroupBox1 + Left = 0 + Height = 228 + Top = 17 + Width = 98 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 2 + BorderSpacing.Right = 6 + BorderSpacing.Bottom = 8 + ItemHeight = 0 + MultiSelect = True + OnSelectionChange = ItemListSelectionChange TabOrder = 0 end - object GridScrChk: TCheckBox - Left = 202 - Height = 19 - Top = 6 - Width = 169 - Caption = 'Put Composite Score in Grid' + object InBtn: TBitBtn[13] + AnchorSideLeft.Control = Bevel1 + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = VarList + Left = 111 + Height = 26 + Top = 17 + Width = 26 + Images = MainDataModule.ImageList + ImageIndex = 1 + OnClick = InBtnClick + Spacing = 0 TabOrder = 1 end + object OutBtn: TBitBtn[14] + AnchorSideLeft.Control = Bevel1 + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = InBtn + AnchorSideTop.Side = asrBottom + Left = 111 + Height = 26 + Top = 47 + Width = 26 + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 8 + Images = MainDataModule.ImageList + ImageIndex = 0 + OnClick = OutBtnClick + Spacing = 0 + TabOrder = 2 + end + object ItemList: TListBox[15] + AnchorSideLeft.Control = AllBtn + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Label2 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = RelList + AnchorSideBottom.Control = GroupBox1 + Left = 150 + Height = 228 + Top = 17 + Width = 98 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 6 + BorderSpacing.Top = 2 + BorderSpacing.Bottom = 8 + ItemHeight = 0 + MultiSelect = True + OnSelectionChange = ItemListSelectionChange + TabOrder = 4 + end + object AllBtn: TBitBtn[16] + AnchorSideLeft.Control = Bevel1 + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = VarList + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = ItemList + Left = 104 + Height = 25 + Top = 119 + Width = 40 + AutoSize = True + Caption = 'All' + OnClick = AllBtnClick + TabOrder = 3 + end + object Bevel1: TBevel[17] + AnchorSideLeft.Control = ParamsPanel + AnchorSideTop.Control = ParamsPanel + AnchorSideRight.Control = ItemList + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 5 + Top = 0 + Width = 248 + Anchors = [akTop, akLeft, akRight] + Shape = bsSpacer + end end - object ResetBtn: TButton - AnchorSideRight.Control = ComputeBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 374 - Height = 25 - Top = 328 - Width = 54 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Reset' - OnClick = ResetBtnClick - TabOrder = 9 - end - object ComputeBtn: TButton - AnchorSideRight.Control = CloseBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom + inherited ParamsSplitter: TSplitter Left = 436 - Height = 25 - Top = 328 - Width = 76 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Compute' - OnClick = ComputeBtnClick - TabOrder = 10 - end - object CloseBtn: TButton - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 520 - Height = 25 - Top = 328 - Width = 55 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Close' - ModalResult = 11 - TabOrder = 11 - end - object HelpBtn: TButton - Tag = 114 - AnchorSideRight.Control = ResetBtn - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 315 - Height = 25 - Top = 328 - Width = 51 - Anchors = [akRight, akBottom] - AutoSize = True - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - BorderSpacing.Right = 8 - BorderSpacing.Bottom = 8 - Caption = 'Help' - OnClick = HelpBtnClick - TabOrder = 8 - end - object ButtonBevel: TBevel - AnchorSideLeft.Control = Owner - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = CloseBtn - Left = 0 - Height = 8 - Top = 312 - Width = 583 - Anchors = [akLeft, akRight, akBottom] - Shape = bsBottomLine - end - object Label1: TLabel - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Owner - Left = 8 - Height = 15 - Top = 8 - Width = 97 - BorderSpacing.Left = 8 - BorderSpacing.Top = 8 - Caption = 'Variables Available' - ParentColor = False - end - object Label2: TLabel - AnchorSideLeft.Control = ItemList - AnchorSideTop.Control = Owner - Left = 180 - Height = 15 - Top = 8 - Width = 76 - BorderSpacing.Top = 8 - Caption = 'Selected Items' - ParentColor = False - end - object VarList: TListBox - AnchorSideLeft.Control = Owner - AnchorSideTop.Control = Label1 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = AllBtn - AnchorSideBottom.Control = GroupBox1 - Left = 8 - Height = 228 - Top = 25 - Width = 120 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 8 - BorderSpacing.Top = 2 - BorderSpacing.Right = 6 - BorderSpacing.Bottom = 8 - Constraints.MinHeight = 200 - ItemHeight = 0 - MultiSelect = True - OnSelectionChange = ItemListSelectionChange - TabOrder = 0 - end - object InBtn: TBitBtn - AnchorSideLeft.Control = Bevel2 - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = VarList - Left = 141 - Height = 26 - Top = 25 - Width = 26 - Images = MainDataModule.ImageList - ImageIndex = 1 - OnClick = InBtnClick - Spacing = 0 - TabOrder = 1 - end - object OutBtn: TBitBtn - AnchorSideLeft.Control = Bevel2 - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = InBtn - AnchorSideTop.Side = asrBottom - Left = 141 - Height = 26 - Top = 55 - Width = 26 - BorderSpacing.Top = 4 - Images = MainDataModule.ImageList - ImageIndex = 0 - OnClick = OutBtnClick - Spacing = 0 - TabOrder = 2 - end - object AllBtn: TBitBtn - AnchorSideLeft.Control = Bevel2 - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = VarList - AnchorSideTop.Side = asrCenter - Left = 134 - Height = 25 - Top = 127 - Width = 40 - AutoSize = True - Caption = 'All' - OnClick = AllBtnClick - TabOrder = 3 - end - object ItemList: TListBox - AnchorSideLeft.Control = AllBtn - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = Label2 - AnchorSideTop.Side = asrBottom - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = GroupBox1 - Left = 180 - Height = 228 - Top = 25 - Width = 120 - Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Left = 6 - BorderSpacing.Top = 2 - BorderSpacing.Bottom = 8 - ItemHeight = 0 - MultiSelect = True - OnSelectionChange = ItemListSelectionChange - TabOrder = 4 - end - object Bevel2: TBevel - AnchorSideLeft.Control = VarList - AnchorSideRight.Control = ItemList - AnchorSideRight.Side = asrBottom - Left = 8 - Height = 8 - Top = 3 - Width = 292 - Anchors = [akTop, akLeft, akRight] - Shape = bsSpacer + Height = 361 end end diff --git a/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.pas b/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.pas index cae5db041..a7f40e503 100644 --- a/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.pas +++ b/applications/lazstats/source/forms/analysis/measurement_programs/comprelunit.pas @@ -3,29 +3,23 @@ unit CompRelUnit; {$mode objfpc}{$H+} +{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} interface uses - Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, - StdCtrls, Buttons, ExtCtrls, - MainUnit, OutputUnit, Globals, DataProcs, MatrixLib, - DictionaryUnit, ContextHelpUnit; + Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, Buttons, ExtCtrls, + MainUnit, Globals, MatrixLib, DictionaryUnit, BasicStatsReportFormUnit; type - { TCompRelFrm } + { TCompRelForm } - TCompRelFrm = class(TForm) - ButtonBevel: TBevel; - Bevel2: TBevel; - HelpBtn: TButton; + TCompRelForm = class(TBasicStatsReportForm) + Bevel1: TBevel; InBtn: TBitBtn; OutBtn: TBitBtn; AllBtn: TBitBtn; - ResetBtn: TButton; - ComputeBtn: TButton; - CloseBtn: TButton; RMatChk: TCheckBox; GridScrChk: TCheckBox; GroupBox1: TGroupBox; @@ -38,115 +32,59 @@ type RelList: TListBox; VarList: TListBox; procedure AllBtnClick(Sender: TObject); - procedure ComputeBtnClick(Sender: TObject); - procedure FormActivate(Sender: TObject); - procedure FormCreate(Sender: TObject); - procedure FormResize(Sender: TObject); - procedure FormShow(Sender: TObject); - procedure HelpBtnClick(Sender: TObject); procedure InBtnClick(Sender: TObject); procedure ItemListSelectionChange(Sender: TObject; {%H-}User: boolean); procedure OutBtnClick(Sender: TObject); procedure RelListClick(Sender: TObject); - procedure ResetBtnClick(Sender: TObject); procedure WeightListClick(Sender: TObject); + private - { private declarations } - FAutoSized: Boolean; - procedure UpdateBtnStates; + + protected + procedure AdjustConstraints; override; + procedure Compute; override; + procedure UpdateBtnStates; override; + function Validate(out AMsg: String; out AControl: TWinControl): Boolean; override; + public - { public declarations } + procedure Reset; override; end; var - CompRelFrm: TCompRelFrm; + CompRelForm: TCompRelForm; + implementation +{$R *.lfm} + uses - Math, Utils; + Dialogs, Math, + Utils, GridProcs; -{ TCompRelFrm } -procedure TCompRelFrm.ResetBtnClick(Sender: TObject); -var - i: integer; +{ TCompRelForm } + +procedure TCompRelForm.AdjustConstraints; begin - VarList.Clear; - ItemList.Clear; - RelList.Clear; - WeightList.Clear; - for i := 1 to NoVariables do - VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); - UpdateBtnStates; + inherited; + + RelList.Width := Max(Label3.Width, Label4.Width); + WeightList.Width := RelList.Width; + + ParamsPanel.Constraints.MinWidth := MaxValue([ + GroupBox1.Width, + 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left, + Max(Label1.Width, Label2.Width)*2 + 2*RelList.Width + + AllBtn.Width + 2*VarList.BorderSpacing.Right + 2*RelList.BorderSpacing.Right]); + + ParamsPanel.Constraints.MinHeight := OutBtn.Top + 4*OutBtn.Height + 3*OutBtn.BorderSpacing.Bottom + + VarList.BorderSpacing.Bottom + GroupBox1.Height + + ButtonBevel.Height + CloseBtn.BorderSpacing.Top + CloseBtn.Height; end; -procedure TCompRelFrm.WeightListClick(Sender: TObject); -var - response: string; - index: integer; -begin - response := InputBox('Test Weight', 'Test weight:', '1.0'); - index := WeightList.ItemIndex; - WeightList.Items.Strings[index] := response; -end; -procedure TCompRelFrm.FormActivate(Sender: TObject); -var - w: Integer; -begin - if FAutoSized then - exit; - - w := MaxValue([HelpBtn.Width, ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]); - HelpBtn.Constraints.MinWidth := w; - ResetBtn.Constraints.MinWidth := w; - ComputeBtn.Constraints.MinWidth := w; - CloseBtn.Constraints.MinWidth := w; - - w := Max(Label1.Width, Label3.Width); - VarList.Constraints.MinWidth := w; - ItemList.constraints.MinWidth := w; - RelList.Constraints.MinWidth := w; - WeightList.Constraints.MinWidth := 2; - - //AutoSize := false; - Constraints.MinHeight := Height; - Width := 4 * w + AllBtn.Width + 6 * VarList.BorderSpacing.Left; - Constraints.MinWidth := Width; - - FAutoSized := True; -end; - -procedure TCompRelFrm.FormCreate(Sender: TObject); -begin - Assert(OS3MainFrm <> nil); -end; - -procedure TCompRelFrm.FormResize(Sender: TObject); -var - w: Integer; -begin - w := (Width - AllBtn.Width - 6*VarList.BorderSpacing.Left) div 4; - VarList.Width := w; - ItemList.Width := w; - RelList.Width := w; - WeightList.Width := w; -end; - -procedure TCompRelFrm.FormShow(Sender: TObject); -begin - ResetBtnClick(self); -end; - -procedure TCompRelFrm.HelpBtnClick(Sender: TObject); -begin - if ContextHelpForm = nil then - Application.CreateForm(TContexthelpForm, ContextHelpForm); - ContextHelpForm.HelpMessage((Sender as TButton).tag); -end; - -procedure TCompRelFrm.AllBtnClick(Sender: TObject); +procedure TCompRelForm.AllBtnClick(Sender: TObject); var i: integer; cellstring : string; @@ -159,53 +97,46 @@ begin WeightList.Items.Add(cellstring); end; VarList.Clear; - InBtn.Enabled := false; - OutBtn.Enabled := true; + UpdateBtnStates; end; -procedure TCompRelFrm.ComputeBtnClick(Sender: TObject); + +procedure TCompRelForm.Compute; var errorcode: boolean = false; - i, j, NoVars, count, col: integer; - Rmat, RelMat: DblDyneMat; - Weights, Reliabilities, VectProd, means, variances, stddevs: DblDyneVec; - CompRel, numerator, denominator, compscore: double; - colnoselected: IntDyneVec = nil; + Rmat: DblDyneMat = nil; + RelMat: DblDyneMat = nil; + Weights: DblDyneVec = nil; + Reliabilities: DblDyneVec = nil; + VectProd: DblDyneVec = nil; + means: DblDyneVec = nil; + variances: DblDyneVec = nil; + stddevs: DblDyneVec = nil; + ColNoSelected: IntDyneVec = nil; + RowLabels: StrDyneVec = nil; cellstring: string; title: string; - RowLabels: StrDyneVec = nil; + i, j, NoVars, count, col: integer; + CompRel, numerator, denominator, compscore: double; lReport: TStrings; begin - if ItemList.Count = 0 then - begin - MessageDlg('No items selected.', mtError, [mbOK], 0); - exit; - end; + SetLength(Rmat, NoVariables+1,NoVariables+1); + SetLength(RelMat, NoVariables+1, NoVariables+1); + SetLength(Weights, NoVariables); + SetLength(Reliabilities, NoVariables); + SetLength(VectProd, NoVariables); + SetLength(means, NoVariables); + SetLength(variances, NoVariables); + SetLength(stddevs, NoVariables); - SetLength(colnoselected,NoVariables); - SetLength(Rmat,NoVariables+1,NoVariables+1); - SetLength(RelMat,NoVariables+1,NoVariables+1); - SetLength(Weights,NoVariables); - SetLength(Reliabilities,NoVariables); - SetLength(VectProd,NoVariables); - SetLength(means,NoVariables); - SetLength(variances,NoVariables); - SetLength(stddevs,NoVariables); - SetLength(RowLabels{%H-},NoVariables); - - // get variable col. no.s selected + // Get selected variables' column numbers NoVars := ItemList.Items.Count; + SetLength(RowLabels, NoVars); + Setlength(ColNoSelected, NoVars); for i := 0 to NoVars-1 do begin - cellstring := ItemList.Items.Strings[i]; - for j := 1 to NoVariables do - begin - if (cellstring = OS3MainFrm.DataGrid.Cells[j,0]) then - begin - colnoselected[i] := j; - RowLabels[i] := cellstring; - end; - end; + RowLabels[i] := ItemList.Items[i]; + ColNoSelected[i] := GetVariableIndex(OS3MainFrm.DataGrid, RowLabels[i]); end; count := NoCases; @@ -213,14 +144,17 @@ begin try lReport.Add('COMPOSITE TEST RELIABILITY'); lReport.Add(''); - lReport.Add('File Analyzed: ' + OS3MainFrm.FileNameEdit.Text); + lReport.Add('File analyzed: ' + OS3MainFrm.FileNameEdit.Text); lReport.Add(''); // get correlation matrix - Correlations(NoVars, colnoselected, Rmat, means, variances, stddevs, errorcode, count); + Correlations(NoVars, ColNoSelected, Rmat, means, variances, stddevs, errorcode, count); if errorcode then - MessageDlg('Zero variance found for a variable.', mtError, [mbOK], 0); + begin + ErrorMsg('Zero variance found for a variable.'); + exit; + end; if RmatChk.Checked then begin @@ -240,9 +174,9 @@ begin for i := 0 to NoVars-1 do begin - Reliabilities[i] := StrToFloat(RelList.Items.Strings[i]); + Reliabilities[i] := StrToFloat(RelList.Items[i]); RelMat[i, i] := Reliabilities[i]; - Weights[i] := StrToFloat(WeightList.Items.Strings[i]); + Weights[i] := StrToFloat(WeightList.Items[i]); end; // get numerator and denominator of composite reliability @@ -271,44 +205,40 @@ begin DynVectorPrint(Reliabilities, NoVars, title, RowLabels, count, lReport); lReport.Add('Composite reliability: %6.3f', [CompRel]); - DisplayReport(lReport); + FReportFrame.DisplayReport(lReport); if GridScrChk.Checked then begin cellstring := 'Composite'; - col := NoVariables + 1; - DictionaryFrm.NewVar(col); - DictionaryFrm.DictGrid.Cells[1,col] := cellstring; - col := NoVariables; - OS3MainFrm.DataGrid.Cells[col,0] := cellstring; - col := NoVariables; + col := GetVariableIndex(OS3MainFrm.DataGrid, cellString); + if col = -1 then + begin + col := NoVariables + 1; + DictionaryFrm.NewVar(col); + DictionaryFrm.DictGrid.Cells[1,col] := cellstring; + col := NoVariables; + OS3MainFrm.DataGrid.Cells[col,0] := cellstring; + col := NoVariables; + end; for i := 1 to NoCases do begin - if not GoodRecord(i, NoVars, ColNoSelected) then + if not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected) then continue; compscore := 0.0; for j := 0 to NoVars-1 do - compscore := compscore + (Weights[j] * StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[colnoselected[j],i]))); + compscore := compscore + (Weights[j] * StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[ColNoSelected[j],i]))); OS3MainFrm.DataGrid.Cells[col,i] := FloatToStr(compscore); end; + GridScrChk.Checked := false; end; finally lReport.Free; - RowLabels := nil; - stddevs := nil; - variances := nil; - means := nil; - VectProd := nil; - Reliabilities := nil; - Weights := nil; - RelMat := nil; - Rmat := nil; - colnoselected := nil; end; end; -procedure TCompRelFrm.InBtnClick(Sender: TObject); + +procedure TCompRelForm.InBtnClick(Sender: TObject); var i: integer; cellstring: string; @@ -331,12 +261,14 @@ begin UpdateBtnStates; end; -procedure TCompRelFrm.ItemListSelectionChange(Sender: TObject; User: boolean); + +procedure TCompRelForm.ItemListSelectionChange(Sender: TObject; User: boolean); begin UpdateBtnStates; end; -procedure TCompRelFrm.OutBtnClick(Sender: TObject); + +procedure TCompRelForm.OutBtnClick(Sender: TObject); var i: Integer; begin @@ -356,7 +288,8 @@ begin UpdateBtnStates; end; -procedure TCompRelFrm.RelListClick(Sender: TObject); + +procedure TCompRelForm.RelListClick(Sender: TObject); var response: string; index: integer; @@ -366,15 +299,53 @@ begin RelList.Items[index] := response; end; -procedure TCompRelFrm.UpdateBtnStates; + +procedure TCompRelForm.Reset; begin + inherited; + + CollectVariableNames(OS3MainFrm.DataGrid, VarList.Items); + ItemList.Clear; + RelList.Clear; + WeightList.Clear; + UpdateBtnStates; +end; + + +procedure TCompRelForm.UpdateBtnStates; +begin + inherited; InBtn.Enabled := AnySelected(VarList); OutBtn.Enabled := AnySelected(ItemList); AllBtn.Enabled := VarList.Items.Count > 0; end; -initialization - {$I comprelunit.lrs} + +function TCompRelForm.Validate(out AMsg: String; out AControl: TWinControl): Boolean; +begin + Result := false; + + if ItemList.Count = 0 then + begin + AMsg := 'No items selected.'; + AControl := VarList; + exit; + end; + + Result := true; +end; + + +procedure TCompRelForm.WeightListClick(Sender: TObject); +var + response: string; + index: integer; +begin + response := InputBox('Test Weight', 'Test weight:', '1.0'); + index := WeightList.ItemIndex; + WeightList.Items.Strings[index] := response; +end; + end. diff --git a/applications/lazstats/source/forms/mainunit.pas b/applications/lazstats/source/forms/mainunit.pas index c9f470013..9f72e3a1e 100644 --- a/applications/lazstats/source/forms/mainunit.pas +++ b/applications/lazstats/source/forms/mainunit.pas @@ -1553,9 +1553,9 @@ end; // Menu "Analysis" > "Measurement Programs" > "Weighted Composite Reliability" procedure TOS3MainFrm.mnuAnalysisMeas_CompositeClick(Sender: TObject); begin - if CompRelFrm = nil then - Application.CreateForm(TCompRelFrm, CompRelFrm); - CompRelFrm.ShowModal; + if CompRelForm = nil then + Application.CreateForm(TCompRelForm, CompRelForm); + CompRelForm.Show; end; // Menu "Analysis" > "Measurement Programs" > "Kuder-Richardson #21 Reliability"