Ahhhhhhhhh, I did not have a chance to read the docs about matchText yet. This why the uselist is one of the best lists around.
I was trying to avoid another user function but it look like stringsAreEqual is going in my master library. Thanks Lyn! Ralph DiMola IT Director Evergreen Information Services rdim...@evergreeninfo.net -----Original Message----- From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of Lyn Teyla Sent: Thursday, September 03, 2015 4:35 PM To: How to use LiveCode Subject: Re: Compare numeric strings with leading zeros Thierry Douez wrote: > on mouseUp > local userTyping = 5 > local myVeryStrongPassword = "005" > if matchText( userTyping, myVeryStrongPassword) then > answer "Great!" > else > answer "Too bad :( try again.." > put "005" into userTyping > if matchText( userTyping, myVeryStrongPassword) then answer "Great!" > end if > end mouseUp I would caution against using matchText for this purpose, because the second parameter is treated by the function as a regular expression. For instance, matchText would return true if you were to reverse your example values: local userTyping = "005" local myVeryStrongPassword = 5 This is because 005 does indeed contain 5. In addition, since passwords are typically allowed to contain any character, including those that have special meaning in regular expressions, something like this would also return true: local userTyping = "5" local myVeryStrongPassword = "^5$" With this in mind, I would go with the method of first checking the length followed by the values as suggested by a couple of previous posters. Since Ralph is looking to use this for password validation, I would throw in a case sensitivity check as well: on mouseUp put stringsAreEqual("005", "5") end mouseUp function stringsAreEqual pString1, pString2 set the caseSensitive to true if (len(pString1) = len(pString2)) and (pString1 = pString2) then return true end if return false end stringsAreEqual Hope this helps! Lyn _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode