Reusable Part S_190RQL
* ===================================================================;
*;
* Component : S_190RQL;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Reusable Question List ;
*;
* 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 DISPLAYPOSITION(1) HEIGHT(163) LAYOUTMANAGER(#ATLM_1) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(600);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#LTVW_1) DISPLAYPOSITION(1) HEIGHT(163) LEFT(0) PARENT(#COM_OWNER) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(0) WIDTH(600);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Center) MANAGE(#LTVW_1) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) PARENT(#LTVW_1) SOURCE(#S_190PQN) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) DISPLAYPOSITION(2) PARENT(#LTVW_1) SOURCE(#S_190PQA) WIDTH(30);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) DISPLAYPOSITION(3) PARENT(#LTVW_1) SOURCE(#S_190PQL) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_4) CAPTION('Sequence') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#LTVW_1) SOURCE(#S_190PQSQ) WIDTH(12);
;
define_evt QuestionSelected help('This event is signaled when a different question has been selected');
define_evt NoQuestionFound help('This event is signaled when there are no questions for this poll');
;
define_pty name(CurrQuestion) get(*auto #S_190PQN ) ;
;
GROUP_BY NAME(#S_GRPPQU) FIELDS(#S_190PID #S_190PQN #S_190PQA #S_190PQL #S_190PQS #S_190PQSQ);
;
EVTROUTINE HANDLING(#LTVW_1.ItemGotFocus) ;
Signal QuestionSelected ;
ENDROUTINE;
*;
* Get all questions for a poll and optionally set the focus to a particular question, otherwise the first question ;
mthroutine uSetPollQues;
Define_Map *Input #S_190PID #mS_190PID Desc('Set the poll ') Help('Set the list to a poll ');
Define_Map *Input #S_190PQN #mS_190PQN Desc('Optionally set the question') Mandatory(0) ;
;
change #S_190PID #mS_190PID.value;
change #S_190PQN #mS_190PQN.value;
;
execute LOADQUES with_parms(#S_190PID #S_190PQN);
;
endroutine;
*;
* Set the focus to a particular question in the same poll, or create a new entry if the question is not found;
mthroutine uSetQuestion;
Define_Map *Input #S_190PQN #mS_190PQN Desc('xxxx') Help('A different question for the same poll');
;
change #S_190PQN #mS_190PQN.value;
;
BEGIN_LOOP;
selectlist #LTVW_1;
continue if('#S_190PQN *ne #mS_190PQN.Value') ;
;
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
* set the field #S_190PQN to the current list entry ;
;
* The following relates to situations where the focus in a list view is set programmatically;
;
* if the following logic was not present, #S_190PQN would contain the value for the list entry that lost focus, instead;
* of the value for the list entry that just got focus. This would cause property uCurrQuestion to be wrong.;
;
CHANGE #STD_IDNO #LTVW_1.FocusItem.Entry;
GET_ENTRY #STD_IDNO #LTVW_1;
signal QuestionSelected;
return;
endselect;
;
* no entry found that matches the question requested - must be a new question;
CHANGE (#S_190PQA #S_190PQL #S_190PQSQ) *NULL;
CHANGE #S_190PQN #mS_190PQN.Value;
;
ADD_ENTRY #LTVW_1;
END_LOOP;
;
endroutine;
*;
* load all questions for the poll into the list box (in sequence order);
Subroutine LOADQUES parms(#S_190PID #S_190PQNW);
DEFINE #S_190PQNW reffld(#S_190PQN);
clr_list #LTVW_1;
select (#S_GRPPQU) from_file(SETPQUL3) with_key(#S_190PID);
add_entry #LTVW_1;
endselect;
;
IF '#S_190PQNW *EQ 0';
get_entry number(1) from_list(#LTVW_1);
if_status (*okay);
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
signal QuestionSelected;
else;
signal NoQuestionFound;
endif;
else;
invoke #com_owner.uSetQuestion mS_190PQN(#S_190PQNW);
endif;
endroutine;
END_COM;
* ===================================================================;
*;
* Component : S_190RQL;
* Type : Reusable Component;
* Ancestor : PRIM_PANL (Primitive Panel);
*;
* Description : Reusable Question List ;
*;
* 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 DISPLAYPOSITION(1) HEIGHT(163) LAYOUTMANAGER(#ATLM_1) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(600);
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LTVW) NAME(#LTVW_1) DISPLAYPOSITION(1) HEIGHT(163) LEFT(0) PARENT(#COM_OWNER) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(0) WIDTH(600);
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Center) MANAGE(#LTVW_1) PARENT(#ATLM_1);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_1) PARENT(#LTVW_1) SOURCE(#S_190PQN) VISIBLE(False) WIDTH(20);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_2) DISPLAYPOSITION(2) PARENT(#LTVW_1) SOURCE(#S_190PQA) WIDTH(30);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_3) DISPLAYPOSITION(3) PARENT(#LTVW_1) SOURCE(#S_190PQL) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_LVCL) NAME(#LVCL_4) CAPTION('Sequence') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#LTVW_1) SOURCE(#S_190PQSQ) WIDTH(12);
;
define_evt QuestionSelected help('This event is signaled when a different question has been selected');
define_evt NoQuestionFound help('This event is signaled when there are no questions for this poll');
;
define_pty name(CurrQuestion) get(*auto #S_190PQN ) ;
;
GROUP_BY NAME(#S_GRPPQU) FIELDS(#S_190PID #S_190PQN #S_190PQA #S_190PQL #S_190PQS #S_190PQSQ);
;
EVTROUTINE HANDLING(#LTVW_1.ItemGotFocus) ;
Signal QuestionSelected ;
ENDROUTINE;
*;
* Get all questions for a poll and optionally set the focus to a particular question, otherwise the first question ;
mthroutine uSetPollQues;
Define_Map *Input #S_190PID #mS_190PID Desc('Set the poll ') Help('Set the list to a poll ');
Define_Map *Input #S_190PQN #mS_190PQN Desc('Optionally set the question') Mandatory(0) ;
;
change #S_190PID #mS_190PID.value;
change #S_190PQN #mS_190PQN.value;
;
execute LOADQUES with_parms(#S_190PID #S_190PQN);
;
endroutine;
*;
* Set the focus to a particular question in the same poll, or create a new entry if the question is not found;
mthroutine uSetQuestion;
Define_Map *Input #S_190PQN #mS_190PQN Desc('xxxx') Help('A different question for the same poll');
;
change #S_190PQN #mS_190PQN.value;
;
BEGIN_LOOP;
selectlist #LTVW_1;
continue if('#S_190PQN *ne #mS_190PQN.Value') ;
;
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
* set the field #S_190PQN to the current list entry ;
;
* The following relates to situations where the focus in a list view is set programmatically;
;
* if the following logic was not present, #S_190PQN would contain the value for the list entry that lost focus, instead;
* of the value for the list entry that just got focus. This would cause property uCurrQuestion to be wrong.;
;
CHANGE #STD_IDNO #LTVW_1.FocusItem.Entry;
GET_ENTRY #STD_IDNO #LTVW_1;
signal QuestionSelected;
return;
endselect;
;
* no entry found that matches the question requested - must be a new question;
CHANGE (#S_190PQA #S_190PQL #S_190PQSQ) *NULL;
CHANGE #S_190PQN #mS_190PQN.Value;
;
ADD_ENTRY #LTVW_1;
END_LOOP;
;
endroutine;
*;
* load all questions for the poll into the list box (in sequence order);
Subroutine LOADQUES parms(#S_190PID #S_190PQNW);
DEFINE #S_190PQNW reffld(#S_190PQN);
clr_list #LTVW_1;
select (#S_GRPPQU) from_file(SETPQUL3) with_key(#S_190PID);
add_entry #LTVW_1;
endselect;
;
IF '#S_190PQNW *EQ 0';
get_entry number(1) from_list(#LTVW_1);
if_status (*okay);
set #LTVW_1.CurrentItem Focus(True) Selected(TRUE) ensurevisible(TRUE);
signal QuestionSelected;
else;
signal NoQuestionFound;
endif;
else;
invoke #com_owner.uSetQuestion mS_190PQN(#S_190PQNW);
endif;
endroutine;
END_COM;