Page 1 of 1
Guessing variable type
Posted: Mon Jun 17, 2013 5:19 pm
by MaxV
Hi again,
I read that there are the
is a ... operator to guess is variable is a:
- array
- boolean
- color
- date
- integer
- number
- point
- rect
but is there an operator that return directly what type of variable is? Like:
and return
number! 
Re: Guessing variable type
Posted: Mon Jun 17, 2013 5:31 pm
by Klaus
Hi Max,
no, there isn't.
Best
Klaus
Re: Guessing variable type
Posted: Tue Jun 18, 2013 6:05 am
by shaosean
You could always write a function to do it..
Re: Guessing variable type
Posted: Tue Jun 18, 2013 9:18 am
by MaxV
Ok, I tried this:
Code: Select all
function type? var
if var is an array then
return "array!"
end if
if var is a boolean then
return "boolean!"
end if
if var is an integer then
return "integer!"
end if
if var is a number then
return "number!"
end if
if var is a point then
return "point!"
end if
if var is a rect then
return "rect!"
end if
if var is a color then
return "color!"
end if
if var is a date then
return "date!"
end if
end type?
But how can I discriminate between string and date?
Re: Guessing variable type
Posted: Tue Jun 18, 2013 11:00 am
by shaosean
if it is a date, then it is not a string
