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

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
lmoriba
Posts: 56
Joined: June 10th, 2018, 6:21 pm

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

Post 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
Attachments
ihs3_test.zip
(101.04 KiB) Downloaded 207 times
2020-02-22.png
2020-02-22.png (114.24 KiB) Viewed 3780 times
btri Arjun
Posts: 37
Joined: August 17th, 2018, 6:09 am

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

Post 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);
lmoriba
Posts: 56
Joined: June 10th, 2018, 6:21 pm

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

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

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

Post 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);
lmoriba
Posts: 56
Joined: June 10th, 2018, 6:21 pm

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

Post by lmoriba »

Thank you Josh. This is exactly the solution am seeking. :D Now is working. Many many thanks, Josh.
KAPALA
Posts: 13
Joined: July 18th, 2017, 1:09 am

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

Post 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
Post Reply