Writing a function to move backward through variables
Posted: February 1st, 2015, 3:17 pm
Hi - this is a little complex to describe, but I'll try. In my questionnaire I have repeated blocks of six questions, and at the end of each block the interviewer may be asked to go back and review incorrect answers. But some of the questions are 'not applicable' as a result of earlier questions, and trying to move into these gives an error message. So I have a piece of code which only moves into a question if isn't not applicable. This works from within a field itself, here's an example for six variables, called FI03_27 to FI03_32 :-
PROC FI03_33
postproc
if FI03_27 <> notappl then move FI03_27
else
if FI03_28 <> notappl then move FI03_28
else
if FI03_29 <> notappl then move FI03_29
else
if FI03_30 <> notappl then move FI03_30
else
if FI03_31 <> notappl then move FI03_31
else
if FI03_32 <> notappl then move FI03_32;
endif;
endif;
endif;
endif;
endif;
endif;
This is a clumsy bit of code, and I need to use it multiple times, so I'd like to put it into a user defined function. Here's an attempt:-
function MoveWithinStaff (alpha Q1, alpha Q2, alpha Q3, alpha Q4, alpha Q5,alpha Q6)
if Q1 <> notappl then move Q1;
else
if Q2 <> notappl then move Q2
else
if Q3 <> notappl then move Q3
else
if Q4 <> notappl then move Q4
else
if Q5 <> notappl then move Q5
else
if Q6 <> notappl then move Q6;
endif;
endif;
endif;
endif;
endif;
endif;
But immediately this gives me an error message at the first if statement:-
ERROR: Invalid character expression near line 55 in GLOBAL procedure
I've quite various things with quotes but it's not made a difference. Any help on where I am going wrong would be very much appreciated.
Many thanks
Keith
PROC FI03_33
postproc
if FI03_27 <> notappl then move FI03_27
else
if FI03_28 <> notappl then move FI03_28
else
if FI03_29 <> notappl then move FI03_29
else
if FI03_30 <> notappl then move FI03_30
else
if FI03_31 <> notappl then move FI03_31
else
if FI03_32 <> notappl then move FI03_32;
endif;
endif;
endif;
endif;
endif;
endif;
This is a clumsy bit of code, and I need to use it multiple times, so I'd like to put it into a user defined function. Here's an attempt:-
function MoveWithinStaff (alpha Q1, alpha Q2, alpha Q3, alpha Q4, alpha Q5,alpha Q6)
if Q1 <> notappl then move Q1;
else
if Q2 <> notappl then move Q2
else
if Q3 <> notappl then move Q3
else
if Q4 <> notappl then move Q4
else
if Q5 <> notappl then move Q5
else
if Q6 <> notappl then move Q6;
endif;
endif;
endif;
endif;
endif;
endif;
But immediately this gives me an error message at the first if statement:-
ERROR: Invalid character expression near line 55 in GLOBAL procedure
I've quite various things with quotes but it's not made a difference. Any help on where I am going wrong would be very much appreciated.
Many thanks
Keith