A string doesn't equal itself
J. Landman Gay
jacque at hyperactivesw.com
Sun Apr 8 00:00:09 EDT 2007
Brent Anderson wrote:
> Hello.
>
> I would imagine that it is making a false detection of your string as a
> number. I replaced the Es with Fs and it worked fine. Until Revolution
> comes out with a correction, you'll have to make the comparison using a
> function to process the data. A sure-fire way to get this to work would
> be to compare the base64 versions of the strings.
>
> It's very odd that revolution doesn't interpret the two strings the same
> (and, therefore, as equal). It makes you wonder what's going on under
> the hood.
That's what I suspected. Rev thinks that a "number" containing a single
"E" is an exponent written in scientific notation. What I think is
happening is that this "large" number forces Rev to use the math
libraries that return fuzzy results when working with numbers containing
many decimal places.
I fixed it by surrounding the variables with specifically inserted quote
marks, which forces Rev to do a string comparison (mainly because I
never thought to use base64 on them.)
put quote & stringOne & quote into tFirst
put quote & stringTwo & quote into tSecond
put tFirst = tSecond --> returns true
Rev's interesting numeric interpretation could mess up anyone who is
generating serial keys like I am. Watch out for "numbers" with a single
"E" in them. My app has generated hundreds of serial keys that all
worked without error until today, when this odd one came through. All
other alpha-numeric sequences seem to work fine without any special
treatment.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list