Hi, I need help with finding an item in a list and replacing it with another item.. For example, when a player would like to change his username, the system will have to grab his username from the USERNAME list and replace it with ANSWER(new username).
Oh btw.. I have 2 different username variables, one "username" which is for user to login with, and the other one is "usernames" which the list of usernames
Since users may want to change their names, you may consider employing a non-mutable user_id as main key for a user’s records.
The user_name would then be in a table relating user_id-s with user_name-s (BTW you may even keep former names of the same user, if you deem such useful).
Changing a user_name would then be done as follows:
I agree, if one hasn’t taken steps preventing keys from being numericnote, use of assoc is to be preferred. The latter is much slower at runtime than (the “dictionary” application of) item of though, which may become an issue when a larger database is involved. Besides, using assoc is slightly less convenient. I recently wrote a simple block (lookup) implementing item of for dictionary applications and supporting numeric keys.
Note: a simple measure is adding a non-numeric prefix (such as: “$”) to each and every key.
To be honest, I didn't think too much about that bit. At least the first method I showed was case insensitive (providing that case sensitivity is turned off).