Logics in table

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
OLODO
Posts: 14
Joined: September 30th, 2016, 3:31 pm
Location: Cotonou (Bénin)

Logics in table

Post by OLODO »

Hello,
I ask for help to write a logic.
Indeed, I realize a data collect in focus group for which, I must inform the function of each member in the group in the variable whose name is LDP_3.
However 2 people can not occupy the same function apart from those who are simple members whose code is 6. The other functions have the following codes: President = 1, Treasurer = 2, Secretary = 3, Advisor = 4 and Warehouse = 5.
The code on the image is written but it only works for a gap of 1 between the rows of the array. At the end of 1 this does not work anymore.
I would like help with writing a global code.

There is also a variable that provides information on the number of focus group participants whose name is NPFG.

Thank you
Attachments
Capture.PNG 1.PNG
Capture.PNG 1.PNG (4.95 KiB) Viewed 3282 times
Capture.PNG
Capture.PNG (10.74 KiB) Viewed 3282 times
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Logics in table

Post by aaronw »

I'm not certain I understand the behavior. Is the goal to add a check, so no two members are a president, treasurer, secretary, adviser, or warehouse?
OLODO
Posts: 14
Joined: September 30th, 2016, 3:31 pm
Location: Cotonou (Bénin)

Re: Logics in table

Post by OLODO »

yes it's my goal
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Logics in table

Post by aaronw »

Here's a simple implementation of a check that will warn you if more than one member is a president, treasurer, secretary, adviser, or warehouse. Notice that the check runs at the end of the roster.
PROC ROSTER_CHECK_REC000

postproc

    numeric presidentCount = 0;
    numeric treasurerCount = 0;
    numeric secretaryCount = 0;
    numeric adviserCount = 0;
    numeric warehouseCount = 0;

    do numeric i = 1 while i <= soccurs(ROSTER_CHECK_REC)

        if ROLE(i) = 1 then
            inc(presidentCount);
        elseif ROLE(i) = 2 then
            inc(treasurerCount);
        elseif ROLE(i) = 3 then
            inc(secretaryCount);
        elseif ROLE(i) = 4 then
            inc(adviserCount);
        elseif ROLE(i) = 5 then
            inc(warehouseCount);
        endif;

    enddo;

    if presidentCount > 1 then
        errmsg("Warning there are %d presidents!", presidentCount);
    endif;

    if treasurerCount > 1 then
        errmsg("Warning there are %d treasurers!", treasurerCount);
    endif;

    if secretaryCount > 1 then
        errmsg("Warning there are %d secretary!", secretaryCount);
    endif;

    if adviserCount > 1 then
        errmsg("Warning there are %d adviser!", adviserCount);
    endif;

    if warehouseCount > 1 then
        errmsg("Warning there are %d warehouse!", warehouseCount);
    endif;
OLODO
Posts: 14
Joined: September 30th, 2016, 3:31 pm
Location: Cotonou (Bénin)

Re: Logics in table

Post by OLODO »

thanks aaronw.
It work
Post Reply