Page 1 of 1

Remove a Value based on a Previous Selection in a roster.

Posted: February 22nd, 2020, 12:00 pm
by lmoriba
Dear CSPRo Community
I have an itemized list running from 1 to 139 items in a roster. However, I don’t want to select this list sequentially. I want to select this list in any order. To avoid inadvertently selecting the same item more than once, if any item is selected from the list that item be automatically removed from the list or drops off from the list, so that you won’t the see the item again in the list. I don’t know if this can be possible in CSPRO.
Attached is the roster, am working on. Thank you.
Image

Re: Remove a Value based on a Previous Selection in a roster.

Posted: February 23rd, 2020, 9:32 am
by btri Arjun
Removing a Value Based on a Previous Selection
Sometimes a questionnaire has a series of questions that asks about preferences, such as, “What is your favorite color?,” and then, “What is your second favorite color?” The list of options for the second question can exclude the selected answer to the first question. The valueset object makes this task very easy:

PROC SECOND_FAVORITE_COLOR

preproc

valueset second_favorite_color_vs = FAVORITE_COLOR_VS;

second_favorite_color_vs.remove(FAVORITE_COLOR);

setvalueset(SECOND_FAVORITE_COLOR, second_favorite_color_vs);

Re: Remove a Value based on a Previous Selection in a roster.

Posted: February 23rd, 2020, 11:47 am
by lmoriba
Arjun,

Thanks for clarifying. As you can see the values and selection does not depend on any values selected before. So, I am looking for a solution that will drop values that have been selected so that they won't appear again. This is necessary to avoid inadvertently selecting any value more than once.

Does CSPro provide solutions for this kind of problems? Please help.

Re: Remove a Value based on a Previous Selection in a roster.

Posted: February 23rd, 2020, 10:20 pm
by josh
In Arjuns example FAVORITE_COLOR is a previous selection. In your case, since there are multiple previous selections you will need to loop to remove all the previous selections. Loop from 1 to the current row of the roster (use currocc() function to get the current row) and remove the value chosen at each row from the selection.

Something like:

Code: Select all

valueset vs = ITEMS_VS;

do i = 1 while i < currocc()
   vs.remove(ITEMS(i))
enddo;

setvalueset(ITEMS, vs);

Re: Remove a Value based on a Previous Selection in a roster.

Posted: February 24th, 2020, 9:43 am
by lmoriba
Thank you Josh. This is exactly the solution am seeking. :D Now is working. Many many thanks, Josh.

Re: Remove a Value based on a Previous Selection in a roster.

Posted: January 12th, 2021, 11:57 am
by KAPALA
I have not get it clear can you send the program with those codes so that i can see how it works? Thank You