Page 1 of 1

ID and Password checking from Arrays in CSPro 8.0

Posted: February 19th, 2025, 4:40 am
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.

Re: ID and Password checking from Arrays in CSPro 8.0

Posted: February 19th, 2025, 5:39 pm
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;

Re: ID and Password checking from Arrays in CSPro 8.0

Posted: February 20th, 2025, 4:40 am
by Rolyno
Thank you Grégory Martin for your helpful responses! Your support really helped me solve my issue.