Page 1 of 1

Logics in table

Posted: March 6th, 2019, 10:22 am
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

Re: Logics in table

Posted: March 6th, 2019, 4:29 pm
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?

Re: Logics in table

Posted: March 6th, 2019, 5:12 pm
by OLODO
yes it's my goal

Re: Logics in table

Posted: March 7th, 2019, 4:46 pm
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;

Re: Logics in table

Posted: March 8th, 2019, 9:12 am
by OLODO
thanks aaronw.
It work