ERROR:You must assign the result of the function to an alpha
ERROR:You must assign the result of the function to an alpha
How can I use logic with alphanumeric fields?
I'm using alphanumeric fields with check box (multiple answers), I would like to code something like "if Q1 does not have A then skip to Q3"
if not Q1 in "A" then
skip to Q3;
endif;
if Q1 in "A" then
move to Q2;
else skip to Q3
endif;
How does alphanumeric coding works in CSPro?
Thank you for any help
I'm using alphanumeric fields with check box (multiple answers), I would like to code something like "if Q1 does not have A then skip to Q3"
if not Q1 in "A" then
skip to Q3;
endif;
if Q1 in "A" then
move to Q2;
else skip to Q3
endif;
How does alphanumeric coding works in CSPro?
Thank you for any help
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: ERROR:You must assign the result of the function to an a
For the benefit of other users, one way to code this would be like this:
if not poschar("A",Q1) then
skip to Q3;
endif;
The poschar function will search the whole Q1 string, looking for "A." If it finds "A" it will return the position of that character. Otherwise it returns 0.skip to Q3;
endif;
Re: ERROR:You must assign the result of the function to an a
I take this old topic because I am struggling to implement additional conditions to the poschar command. For example, how could I include to Gregory's code the additional condition that Q2 should not include "C"?
Thank you,
Giacomo
Thank you,
Giacomo
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: ERROR:You must assign the result of the function to an a
If your condition is:
"If Q1 does not have A and Q2 does not have B then then skip to Q3"
You would write it:
"If Q1 does not have A and Q2 does not have B then then skip to Q3"
You would write it:
if not poschar("A",Q1) and not poschar("B",Q2) then
skip to Q3;
endif;
skip to Q3;
endif;
Re: ERROR:You must assign the result of the function to an a
Thanks Gregory - I much grateful for your help.
Giacomo
Giacomo
Re: ERROR:You must assign the result of the function to an a
Gregory,
I have some hard times to implement this condition to a function. Let us assume that we would like Q4 equals to 0 if Q1 includes A or B (or both).
Q4 is a protected field. I may need to use a specific function, but I am not sure which one is appropriate...
Thank you very much,
Giacomo
I have some hard times to implement this condition to a function. Let us assume that we would like Q4 equals to 0 if Q1 includes A or B (or both).
Code: Select all
PROC Q4
if poschar("A",Q1) or poschar("B",Q1) then
Q4 = 0;
endif;
Thank you very much,
Giacomo
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: ERROR:You must assign the result of the function to an a
If Q4 is protected, you need to assign a value to it before the field is reached. Try code like this:
PROC Q4
preproc
if poschar("AB",Q1) then
Q4 = 0;
endif;
preproc
if poschar("AB",Q1) then
Q4 = 0;
endif;
Re: ERROR:You must assign the result of the function to an a
Thanks Gregory. It worked fine, I just added a "else". For the benefit of future readers:
Giacomo
PROC Q4
preproc
if poschar("AB",Q1) then
Q4 = 0;
else
Q4 = 1;
endif;
Have a nice day,preproc
if poschar("AB",Q1) then
Q4 = 0;
else
Q4 = 1;
endif;
Giacomo