Forum Discussion

bernie_zhao's avatar
14 years ago

object comparison

Hi I'm a newbie to Roku.
A very basic question, how do you compare two objects.
Obviously I didn't expect the following not work

a={ a1:"ok" }
b={ b1:"ok2" }
c = a
if a=c then ' this line generates "Type Mismatch"
endif

In debug console, I tried ?a=b or ?a<>b, both generate same type mismatch error.

In Roku SDK it says objects are assigned by reference, which leads me to naturally believe object comparison is same as other languages such as java, javascript, c#...etc.

Any help is appreciated!

3 Replies

  • A little more context...

    I'm storing a bunch of objects (AA) in an array.
    And upon removal I need to find the object and delete it from array.
    I'm looping the array to "find it". But in order to find it I need to compare the one I'm searching for with the one in the array.
    Hence the question.
  • I don't think Brightscript supports comparisons between AAs. You could add an integer ID value to each of your AAs and compare that.

    --Mark
  • Thanks Mark!
    So I assume the limitation is not only on AA, but also on all objects that you created by CreateObject?

    This sounds a little tricky if you want to maintain your own stack of screen objects.