May I know if any command is available in SenseTalk to check a variable or value is of type String/text, Rectangle, list, etc. Appreciate any help.
How about writing a function using "Is A"
operator?
1 Like
Thanks, this helps. I was trying like text, string, etc… didn’t try letters .
Here is the code for determining if a variable contains a rectangle.
put (0,0,460,120) into myRectangle
put VerifyRectangle(myRectangle)
//A rectangle is defined as a four item list in which each is numeric
to VerifyRectangle myRectangle
put myRectangle is a list into tfList
if tfList is false then
Return false
Exit Handler
end if
put the number of items of myRectangle is 4 into tfNumberOfItems
if tfNumberOfItems is false then
Return false
Exit Handler
end if
repeat with each item of myRectangle
put IT is a number into tfNumeric
if tfNumeric is false then
Return false
Exit Handler
end if
end repeat
return true
end VerifyRectangle
1 Like
Unfortunately, that’s doing it the hard way (and doesn’t account for the fact that a rectangle in SenseTalk can be either a list of 4 coordinates or a list of 2 points). Keiichi_Yamamoto had the right idea – just use the is a
operator:
put [[0,0],[460,120]] into myRectangle
put myRectangle is a rectangle --> True
1 Like