Forcing string comparisons, or When is "0" not 0?
Peter Haworth
pete at lcsql.com
Thu Oct 15 15:36:49 EDT 2015
There is a new operator in LC8, "is really" which may help the
string/number comparison issue. See the LC8 dictionary for details.
Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
On Thu, Oct 15, 2015 at 12:35 PM, Ralph DiMola <rdimola at evergreeninfo.net>
wrote:
> I had a thread a month or 2 ago (Compare numeric strings with leading
> zeros). I needed to make sure that 0123 <> 123 for password validation.
> There were many good suggestions but I finally wound up with:
>
> 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
>
> Something built in would be better. If "0123" is exactly "123" then...
> would work for me
>
> Now, should "is exactly" respect the caseSensitive property? If not then
> "exactly" would mean just what is says "EXACTLY". But respecting the
> caseSensitive property would be more flexible.
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdimola at evergreeninfo.net
> Phone: 518-636-3998 Ex:11
> Cell: 518-796-9332
>
>
> -----Original Message-----
> From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On
> Behalf Of Geoff Canyon
> Sent: Thursday, October 15, 2015 2:48 PM
> To: How to use LiveCode
> Subject: Re: Forcing string comparisons, or When is "0" not 0?
>
> On 2015-10-14 22:19, Devin Asay wrote:
>
> > Shouldn’t there be a way to force a string comparison? I know LC tries
> > to be all helpful about casting numerals as numbers, but what if I
> > want to know if it’s the exact string?
> >
>
> I think you have come up with the best syntax right there.
>
> put 3 is "3" -- true
> put 3 is "3.0" -- true
> put 3 is 2.999999999999999 -- true
>
> put 3 is exactly "3" -- false
> put 3 is exactly "3.0" -- false
> put "3" is exactly "3" -- true
> put 3 is exactly 3 -- true
> put 3 is exactly 3.0 -- true
> put 3 is exactly 2.999999999999999 -- false
> _______________________________________________
> use-livecode mailing list
> use-livecode at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list