Question (more or less) about arrays

jbv jbv.silences at club-internet.fr
Tue Apr 3 04:47:25 EDT 2007


Hi all,

Please test this little script :

on mouseUp
  put 0 into var[1]
  put 0 into var[2]
  if var = empty then
    put 0
  else
    put 1
  end if
end mouseUp

In order to check if array "var" contains any element,
the following test must be used instead :
    if the keys of var = empty then

I was just wondering if you guys would find this behaviour
"normal" ? I've just lost more than 1 hour trying to debug a
script in which I need to test the content of different variables
(some arrays, some made of lines of items), and thought
(naively ?) that any array would be considered as "not empty"
as soon as it contains at least 1 key...
Obviously I was wrong, as it seems that "empty" applies only
to variables containing straight text...

I don't have any recent Rev doc at hand, only an old MC version,
and the doc doesn't say much on this topic... May be Rev docs
are more explicit...

Best,
JB




More information about the use-livecode mailing list