Skip to first unread message

VasilisMp

unread,
May 5, 2019, 11:19:34 AM5/5/19
to MIT App Inventor Forum
Hello guys! I have 2 lists. On the first list i save the names and on the other i save the passwords. On the list with the names i dont let the user input the same name. But on the list with the passwords i dont want something like that. I mean every user (with a different name) can input the same password. However, i cant compare the indexes of the two lists. For example, lets say that on the names list i have the names: abc, efg and on the passwords list i have: 123, 456. In this case i can program it to make the "abc" user only login with the password "123" and not with the password "456". But if i have this: abc, efg and : 123, 123 i cant program it to make both of the users connect with the same password...Any help? 

TimAI2

unread,
May 5, 2019, 11:31:51 AM5/5/19
to MIT App Inventor Forum
It sounds like you didn't follow my advice, or use the blocks / aia I provided from your previous post to use a single list (of lists) or lists of pairs.
Doing it that way will allow for duplicates in either user or password

VasilisMp

unread,
May 5, 2019, 12:44:49 PM5/5/19
to MIT App Inventor Forum
I appreciate your work bro, but i cant understand your code and in the same time i figured out an easier (and simpler) way to do the same thing as you except the above... I just wanted to know if there is a way to solve the problem that came up.

TimAI2

unread,
May 5, 2019, 1:41:38 PM5/5/19
to MIT App Inventor Forum
But your "easier and simpler way" is causing problems

Ai2 lists don't cope very well with duplicate entries in single lists

Here is a method to overcome this, will mean more work with your easier method though....

TimAI2

unread,
May 5, 2019, 7:50:02 PM5/5/19
to MIT App Inventor Forum
One thought, if your user names are unique, use the index of that list to get the password with the same index in the password list

VasilisMp

unread,
May 6, 2019, 11:41:05 AM5/6/19
to MIT App Inventor Forum
Can you, please, provide this information with code?

TimAI2

unread,
May 6, 2019, 12:05:21 PM5/6/19
to MIT App Inventor Forum
for example:

blocksmatchlistitemusingindex.png


VasilisMp

unread,
May 6, 2019, 3:45:24 PM5/6/19
to MIT App Inventor Forum
I dont use ListView. I dont save items into lists like your way but i save the names on a gloal variable names "names" and the passwords on a global variable named "passwords". The main goal is, many people can login with the same password (of course they have different names). Can it be done? I tried a lot...

TimAI2

unread,
May 6, 2019, 4:35:27 PM5/6/19
to MIT App Inventor Forum
The listpicker is there for demonstration/example purposes only - it could be a textbox, the value of which is then tested against in the first list

My example provides you with two lists with aligned indexes, the index 1 in the first list relates to index 1 of the second list.

When you select/find/enter an item from the first list (which has unique values) you are selecting by the value in the list, but you also get the index of that item
Because the indexes of the two lists are aligned, you can use the index of the found item in the first list to retrieve the value in the second list using the index from the first.

Thus in my example if you select abc in the first list you will get 123 from the second list - both have the index of 1
If you select ghi in the first list you will get 789 from the second list - both have the index of 3

If you do not "get" this, then i suggest you read up, read up on Lists, and do some tutorials:
.

VasilisMp

unread,
May 7, 2019, 8:57:27 AM5/7/19
to mitappinv...@googlegroups.com
I understand a lot of lists. I also understand your example. Maybe the screenshot will help. As you see on the screenshot i have this program. It works perfectly only if i put different passwords. If i put the same passwords in many different names it runs the else sections and shows "wrong password". This happens because my program understands the same passwords (which every password is a different index) as one index. Therefore if i put something like that:
names: "abc", "klm"
passwords: "123", "123"
The program cant understand that every password is a different index and thats why the if global index name 2 = global index passwords 2 cant work...
Untitled.png

TimAI2

unread,
May 7, 2019, 9:56:57 AM5/7/19
to mitappinv...@googlegroups.com
At the risk of repeating myself....

In your original post, you say: "i dont let the user input the same name"
therefore we can assume that all the usernames are unique.
When a user inputs their user name and password
We can test if the username is in the names2 list
If it is, we can test if the password supplied matches the password stored at the same index for the username, but in the passwords2 list
If this is successful , then so is the login.

blocks-arrgh.png


VasilisMp

unread,
May 8, 2019, 9:38:16 AM5/8/19
to mitappinv...@googlegroups.com
Thanks a lot bro it works just fine! 
Reply all
Reply to author
Forward
0 new messages