Form S_190FG

LANSA

Form S_190FG

*===================================================================;
*;
* Component : S_190FG;
* Type : Form;
* Ancestor : PRIM_FORM (Primitive Form);
*;
* Description : Are the responses to two questions related; ;
*;
* Full Description; This form compares the responses to two questions ;
* looking for a difference between the expected probability of;
* a response combination if the responses ;
* are unrelated, and the actual probability of a response combination.;
*;
* Disclaimer : The following material is supplied as sample material;
* only. No warranty concerning this material or its use;
* in any way whatsoever is expressed or implied.;
*;
* ===================================================================;
;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM CAPTION('Are the responses to two questions related?') FORMSTYLE(Owned) FRAMESTYLE(Single) HEIGHT(525) LEFT(166) MENUBAR(#MBAR_1) TOP(142) VISUALSTYLE(#VS_NORM) WIDTH(858);
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID_1) COLUMNBUTTONHEIGHT(50) DISPLAYPOSITION(1) HEIGHT(209) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TOP(104) WIDTH(297);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_1) CAPTIONTYPE(Label) PARENT(#GRID_1) SOURCE(#S_190PSNA) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_2) CAPTIONTYPE(Label) PARENT(#GRID_1) SOURCE(#S_190PSNB) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_3) CAPTION('Combination of Responses') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#GRID_1) SOURCE(#S_190PSL) WIDTH(51) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_4) CAPTIONTYPE(ColumnHeadings) DISPLAYPOSITION(3) PARENT(#GRID_1) READONLY(False) SOURCE(#S_190CAB) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_5) CAPTIONTYPE(ColumnHeadings) DISPLAYPOSITION(2) PARENT(#GRID_1) SOURCE(#S_190CABE) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GRPH) NAME(#GRPH_1) CAPTION('Frequencies of combinations of responses - Expected and Actual - for all combinations of responses') DISPLAYPOSITION(1) HEIGHT(474) LEFT(4) PARENT(#GPBX_2) SCATTERSTYLE(SymbolAtPoints+Solid) SURFACESTYLE(ConnectLinesInBlack) TABPOSITION(1) TOP(11) VISUALSTYLE(#VS_NORM) WIDTH(524) XCAPTION('Response combinations') YCAPTION('Frequency of this response combination');
DEFINE_COM CLASS(#PRIM_GRCL) NAME(#GRCL_1) COLUMNSYMBOL(Cross) DISPLAYPOSITION(3) PARENT(#GRPH_1) SOURCE(#S_190CAB);
DEFINE_COM CLASS(#PRIM_GRCL) NAME(#GRCL_2) COLUMNSYMBOL(HollowUpTriangle) DISPLAYPOSITION(1) PARENT(#GRPH_1) SOURCE(#S_190CABE);
DEFINE_COM CLASS(#PRIM_GRCL) NAME(#GRCL_3) COLUMNROLE(Label) DISPLAYPOSITION(2) PARENT(#GRPH_1) SOURCE(#S_190PSL);
DEFINE_COM CLASS(#VL_SAM003) NAME(#VL_SAM003);
DEFINE_COM CLASS(#PRIM_MBAR) NAME(#MBAR_1) PARENT(#COM_OWNER);
DEFINE_COM CLASS(#S_190RQN) NAME(#S_190RQNA) LEFT(9) PARENT(#GPBX_1) TABPOSITION(2) TABSTOP(False) TOP(16);
DEFINE_COM CLASS(#S_190RQN) NAME(#S_190RQNB) DISPLAYPOSITION(2) LEFT(9) PARENT(#GPBX_1) TABSTOP(False) TOP(54);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Choose the two questions') DISPLAYPOSITION(2) HEIGHT(87) LAYOUTMANAGER(#FWLM_1) LEFT(7) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) WIDTH(298);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_1) CAPTION('On this form, we are trying to determine whether there is a relationship between the responses to one question and the responses to another. If there is no relationship, then the probability of any combination of responses to the two questions should be roughly the same as the probability of the first response (to question 1) x the probability of the second response (to question 2). The expected shows probability 1 x probability 2. The actual shows how many times the combination actually occurred.') DISPLAYPOSITION(3) HEIGHT(121) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(320) WIDTH(297);
DEFINE_COM CLASS(#PRIM_FWLM) NAME(#FWLM_1) DIRECTION(TopToBottom) FLOWOPERATION(Center) FLOWOPERATIONVER(Spread);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_1) MANAGE(#S_190RQNA) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_2) MANAGE(#S_190RQNB) PARENT(#FWLM_1);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_2) DISPLAYPOSITION(4) HEIGHT(489) LAYOUTMANAGER(#ATLM_1) LEFT(309) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(0) WIDTH(532);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_1) ATTACHMENT(Center) MANAGE(#GRPH_1) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_2) CAPTION('If the expected differs from the actual for a large number of responses, we suspect there is a relationship between the responses') DISPLAYPOSITION(5) HEIGHT(42) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(5) TABSTOP(False) TOP(448) VISUALSTYLE(#VS_EMPH) WIDTH(297);
;
;
EVTROUTINE handling(#com_owner.Initialize);
ENDROUTINE;
*;
* Allow form S_190FA to display this form;
MthRoutine uQuesRelationship;
Define_Map *Input #S_190PID #mS_190PID Desc('Poll Identifier') ;
Define_Map *Input #S_190PQN #mS_190PQN Desc('Question to be analysed') ;
;
DEFINE #S_190PQNW reffld(#S_190PQN);
DEFINE #S_190PIDW reffld(#S_190PID);
;
CHANGE #S_190PIDW #mS_190PID.Value;
CHANGE #S_190PQNW #mS_190PQN.Value;
;
;
* build the combo box of questions for this poll if the poll is different;
IF '#S_190PID *NE #S_190PIDW';
CHANGE #S_190PID #S_190PIDW;
* build the combo box of questions for this poll if the poll is different;
invoke #S_190RQNA.uSetPollQues mS_190PID(#S_190PIDW) mS_190PQN(#S_190PQNW);
invoke #S_190RQNB.uSetPollQues mS_190PID(#S_190PIDW) mS_190PQN(0);
else;
* reposition if the poll is the same ;
invoke #S_190RQNA.uSetQuestion mS_190PQN(#S_190PQNW);
invoke #S_190RQNB.uSetQuestion mS_190PQN(0);
endif;
;
invoke #Com_Owner.ShowForm;
;
return;
endroutine;
;
* Question A selected;
evtroutine handling(#S_190RQNA.QuestionSelected);
CHANGE #S_190PQNA #S_190RQNA.CurrQuestion;
execute GETSELS;
endroutine;
;
* Question B selected;
evtroutine handling(#S_190RQNB.QuestionSelected);
CHANGE #S_190PQNB #S_190RQNB.CurrQuestion;
execute GETSELS;
endroutine;
*;
* When two questions have been selected ;
subroutine GETSELS;
if '(#S_190PQNA *NE 0) *AND (#S_190PQNB *NE 0)';
;
DEFINE #S_190QCNT *DEC 5 0 Desc('number of responses for the question');
DEFINE #S_190RACT *DEC 5 0;
DEFINE #S_190RBCT *DEC 5 0 ;
DEFINE #S_190ABCT *DEC 5 0;
DEFINE #S_190PSN1 reffld(#S_190PSNA);
DEFINE #S_190PSN2 reffld(#S_190PSNB);
DEFINE #S_190PSLW reffld(#S_190PSL);
;
;
DEF_LIST #S_WRKPSNA (#S_190PSNA #S_190PSA #S_190RACT) TYPE(*WORKING);
DEF_LIST #S_WRKPSNB (#S_190PSNB #S_190PSA #S_190RBCT) TYPE(*WORKING);
DEF_LIST #S_WRKAB ( #S_190PSN1 #S_190PSN2 #S_190ABCT) TYPE(*WORKING);
;
CLR_LIST #S_WRKPSNA;
CLR_LIST #S_WRKPSNB;
CLR_LIST #S_WRKAB;
CLR_LIST #GRID_1;
;
;
CHANGE #S_190QCNT *NULL;
SELECT (#S_190PSN #S_190PSA) SETPQS with_key(#S_190PID #S_190PQNA);
* count the number of repondents that chose this option of this question ;
CHANGE #S_190RACT *NULL;
SELECT #S_190RID SETPRAL1 with_key(#S_190PID #S_190PQNA #S_190PSN);
CHANGE #S_190RACT '#S_190RACT + 1';
* get the total number of responses to the question as well;
CHANGE #S_190QCNT '#S_190QCNT + 1';
ENDSELECT;
CHANGE #S_190PSNA #S_190PSN;
ADD_ENTRY #S_WRKPSNA;
ENDSELECT;
;
SELECT (#S_190PSN #S_190PSA) SETPQS with_key(#S_190PID #S_190PQNB);
* count the number of repondents that chose this option of this question ;
CHANGE #S_190RBCT *NULL;
SELECT #S_190RID SETPRAL1 with_key(#S_190PID #S_190PQNB #S_190PSN);
CHANGE #S_190RBCT '#S_190RBCT + 1';
ENDSELECT;
CHANGE #S_190PSNB #S_190PSN;
ADD_ENTRY #S_WRKPSNB;
ENDSELECT;
;
;
* Determine the actual frequencies for each combination of responses;
Select (#S_190RID #S_190PSN) SETPRAL1 with_key(#S_190PID #S_190PQNA);
CHANGE #S_190PSNA #S_190PSN;
CHANGE #S_190PSN *NULL;
* get the same user's response to question B;
FETCH (#S_190PSN) SETPRA with_key(#S_190PID #S_190RID #S_190PQNB) ;
CHANGE #S_190PSNB #S_190PSN;
LOC_ENTRY #S_WRKAB WHERE('(#S_190PSN1 *EQ #S_190PSNA) *AND (#S_190PSN2 *EQ #S_190PSNB)');
IF_STATUS *OKAY;
CHANGE #S_190ABCT '#S_190ABCT + 1';
UPD_ENTRY #S_WRKAB;
ELSE;
CHANGE #S_190PSN1 #S_190PSNA;
CHANGE #S_190PSN2 #S_190PSNB;
CHANGE #S_190ABCT 1;
ADD_ENTRY #S_WRKAB;
ENDIF;
;
endselect;
;
SELECTLIST #S_WRKPSNA;
CHANGE #S_190PSLW #S_190PSA;
SELECTLIST #S_WRKPSNB;
* summary of the combination of answers to the two questions ;
USE BUILTIN(BCONCAT) WITH_ARGS(#S_190PSLW '''-''' #S_190PSA) TO_GET(#S_190PSL);
;
* Determine the expected frequencies ( = probability of response A x probability of response B x the total responses);
CHANGE #S_190CABE '(#S_190RACT * #S_190RBCT) / #S_190QCNT';
;
* Get the actual frequency for the combination;
CHANGE #S_190CAB 0;
LOC_ENTRY #S_WRKAB WHERE('(#S_190PSN1 *EQ #S_190PSNA) *AND (#S_190PSN2 *EQ #S_190PSNB)');
IF_STATUS *OKAY;
CHANGE #S_190CAB #S_190ABCT;
ENDIF;
*;
ADD_ENTRY #GRID_1;
ENDSELECT;
ENDSELECT;
;
* move the data into the graph;
CLR_LIST #GRPH_1;
SELECTLIST #GRID_1;
ADD_ENTRY #GRPH_1;
endselect;
;
else;
* a pair of questions has not yet been selected;
CLR_LIST #GRPH_1;
CLR_LIST #GRID_1;
endif;
;
ENDROUTINE;
END_COM;