ERROR:You must assign the result of the function to an alpha

Discussions about CSEntry
Guest

ERROR:You must assign the result of the function to an alpha

Post by Guest »

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
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: ERROR:You must assign the result of the function to an a

Post by lls »

Resolved
Gregory Martin
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

Post by Gregory Martin »

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.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: ERROR:You must assign the result of the function to an a

Post by lls »

Thank you
giacomoz
Posts: 8
Joined: August 7th, 2013, 4:32 am

Re: ERROR:You must assign the result of the function to an a

Post by giacomoz »

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
Gregory Martin
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

Post by Gregory Martin »

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 not poschar("A",Q1) and not poschar("B",Q2) then
    
skip to Q3;
endif;
giacomoz
Posts: 8
Joined: August 7th, 2013, 4:32 am

Re: ERROR:You must assign the result of the function to an a

Post by giacomoz »

Thanks Gregory - I much grateful for your help.

Giacomo
giacomoz
Posts: 8
Joined: August 7th, 2013, 4:32 am

Re: ERROR:You must assign the result of the function to an a

Post by giacomoz »

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).

Code: Select all

PROC Q4
if poschar("A",Q1) or poschar("B",Q1) then
    Q4 = 0;
endif;
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
Gregory Martin
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

Post by Gregory Martin »

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;
Guest

Re: ERROR:You must assign the result of the function to an a

Post by Guest »

Thanks Gregory. It worked fine, I just added a "else". For the benefit of future readers:
PROC Q4

preproc

if poschar("AB",Q1) then
Q4 = 0;
else
Q4 = 1;
endif;
Have a nice day,
Giacomo
Post Reply