eggplant

How to log object properties in SenseTalk


What's the easiest way to log all the properties of an object in SenseTalk?

Like this C# example but for eggplant scripting?


Solution

  • In sense talk objects are represented as propertyLists. You can iterate over the keys of an object using the exact same syntax as you would with a propertyList.

    set mike to {current:["Mike and the Mechanics","Genesis"],previous:"Red 7"}
    
    repeat with each item of keys(mike)
      put it & ": " & property (it) of mike
    end repeat
    
    // current: [Mike and the Mechanics,Genesis]
    // previous: Red 7