In CSPro there is no simple way to change the order that questions are asked in a data entry application, but it can be done with some logic. The following code is an example of how one can use logic to randomize the order that questions are asked. The code randomizes the order in which five questions, the field names of which are listed in the fieldNames array, are asked.
PROC GLOBAL
numeric numQuestions = 5;
array questionOrder(5);
array alpha fieldNames(5) = "QUESTION1","QUESTION2","QUESTION3","QUESTION4","QUESTION5";
alpha fieldName;
function gotoQuestion(questionNumber)
fieldName = fieldNames(questionNumber);
move to fieldName;
end;
function nextQuestion()
fieldName = getsymbol();
// see where we are in the list
numeric i;
do i = 1 while fieldNames(i) <> fieldName
enddo;
// now i points to what question number we're on
// now find out where in the order it is
numeric j;
do j = 1 while questionOrder(j) <> i
enddo;
if j = numQuestions then
move to ANOTHER_QUESTION; // we are done with the rotating questions
else
gotoQuestion(questionOrder(j + 1));
endif;
end;
function startQuestions()
numeric i,j;
do i = 1 while i <= numQuestions
questionOrder(i) = random(1,numQuestions);
// see if this question has already been inserted
do j = ( i - 1 ) while j > 0 by (-1)
if questionOrder(j) = questionOrder(i) then // the new value is a repeat
j = 0; // this will terminate the inner do loop
i = i - 1; // this will force the outer do loop to repeat for this value
endif;
enddo;
enddo;
gotoQuestion(questionOrder(1));
end;
PROC CHANGEQUESTIONORDER_FF
preproc
seed(systime());
PROC CHANGEQUESTIONORDER_ID
startQuestions();
PROC QUESTION1
nextQuestion();
PROC QUESTION2
nextQuestion();
PROC QUESTION3
nextQuestion();
PROC QUESTION4
nextQuestion();
PROC QUESTION5
nextQuestion();