Problem with operator "is an integer"

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

Problem with operator "is an integer"

Post by Daross » Thu Mar 20, 2014 6:54 pm

Hi all,
I created this function which return if the number is true or false

Code: Select all

function theInteger pNumber
   return pNumber is an integer
end theInteger
What I do not understand why it is not a false return false

Code: Select all

put theInteger(8.4/1.2) --> return false!
  
I created a stack to explain better the problem (the script is in the button)
Thanks in advance
Attachments
False numbers.livecode.zip
(2.33 KiB) Downloaded 215 times

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Problem with operator "is an integer"

Post by Klaus » Thu Mar 20, 2014 7:03 pm

HI Daross,

you are supplying an expression and not a "simple" number in the parameter! 8)

But you can force LC to evaluate that one before checking for integer, just use VALUE:

Code: Select all

function theInteger pNumber
   return VALUE(pNumber) is an integer
end theInteger
Tested and works!


Best

Klaus

Daross
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Thu Jun 04, 2009 8:15 pm

Re: Problem with operator "is an integer"

Post by Daross » Thu Mar 20, 2014 7:13 pm

Hey Klaus thanks for the trick!
Works well! :D

Post Reply