ID and Password checking from Arrays in CSPro 8.0

Discussions about CSEntry
Post Reply
Rolyno
Posts: 11
Joined: February 19th, 2025, 3:44 am
Location: Cotonou

ID and Password checking from Arrays in CSPro 8.0

Post by Rolyno »

Hello everyone,

I have a small issue with CSPro version 8.0. I want each enumerator to enter an ID and password before proceeding with the rest of the questionnaire.

To achieve this, I created two arrays:

One for IDs
One for passwords, where each password corresponds to a specific ID.
Here is my current setup:

Code: Select all

Array numeric mot_pass(14) = 5635, 3163, 1266, 3808, 2042, 7407, 3340, 6056, 1712, 3074,  
    6599, 3818, 3533, 6236; 

Array string id(14) = "ENQUETEUR1", "ENQUETEUR2", "ENQUETEUR3", "ENQUETEUR4", "ENQUETEUR5",  
    "ENQUETEUR6", "ENQUETEUR7", "ENQUETEUR8", "ENQUETEUR9", "ENQUETEUR10",  
    "ENQUETEUR11", "ENQUETEUR12", "ENQUETEUR13", "ENQUETEUR14"; 

Now, I need a logical condition to verify that the entered ID matches the correct password.
For example, if the user enters "ENQUETEUR1", the password must be "5635", and so on for the rest of the list.

How can I implement this verification in CSPro?

Any help would be greatly appreciated.
Gregory Martin
Posts: 1882
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: ID and Password checking from Arrays in CSPro 8.0

Post by Gregory Martin »

If you use List objects instead of Array objects, you can use the seek function to lookup the interviewer and then check the password. For example:
List mot_pass =
    5635, 3163, 1266, 3808, 2042, 7407, 3340, 6056, 1712, 3074
    6599, 3818, 3533, 6236;

List string id =
    "ENQUETEUR1", "ENQUETEUR2", "ENQUETEUR3", "ENQUETEUR4", "ENQUETEUR5"
    "ENQUETEUR6", "ENQUETEUR7", "ENQUETEUR8", "ENQUETEUR9", "ENQUETEUR10"
    "ENQUETEUR11", "ENQUETEUR12", "ENQUETEUR13", "ENQUETEUR14";

numeric id_index = id.seek(ENQUETEUR);

if id_index = 0 then
    errmsg
("Invalid interviewer.");
    reenter;
endif;

if PASSWORD <> mot_pass(id_index) then
    errmsg
("Invalid password.");
    reenter;
endif;
Rolyno
Posts: 11
Joined: February 19th, 2025, 3:44 am
Location: Cotonou

Re: ID and Password checking from Arrays in CSPro 8.0

Post by Rolyno »

Thank you Grégory Martin for your helpful responses! Your support really helped me solve my issue.
Post Reply