Is it possible to “print” or enumerate an associative array in the debugger? If yes, how so?
roAssociativeArray supports the ifEnum interface, so you can just say
for each key in aa ...
Several of the examples have a PrintAA function that will print an AssociativeArray using this technique.
–Mark
“print” comes to mind :). Seriously though, the print output has improved recently (7.1). Cue:
BrightScript Debugger> ? config
<Component: roAssociativeArray> =
{
init1: 5
init2: 1332175218
name: Kuro%.2s%s
origin: http://localhost
servers: <Component: roArray>
}
When i want to see the nested data, i’d use “? formatJSON(…)”
“EnTerr” wrote:
“print” comes to mind :). Seriously though, the print output has improved recently (7.1).
I noticed that. I was like "why is it printing that array?
“EnTerr” wrote:
When i want to see the nested data, i’d use “? formatJSON(…)”
Great idea. Thanks
Secondary question: How do I print an associative array in this scenario?
<Component: roArray> =
[
<Component: roAssociativeArray>
]
I should pay more attention the answers:
? formatJSON(myVariable)
Does the job, thanks all!
“pcnweb” wrote:
Secondary question: How do I print an associative array in this scenario?
Yep, serializing to JSON will do it if bearable enough to watch. Or looking at the above, you got yourself an “array of dictionaries” [{}], so to see what’s inside, have to peel the top level first, e.g. “? myVar[0]” will print you the top level of the AA. I know, can be confusing - but at least now PRINT mentions the type and shows the or { } brackets, before if i remember it would just dump the content. BEFORE it was something like:
BrightScript Debugger> ? [ { } ]
<Component: roAssociativeArray>
