Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
pcnweb
Level 7

Debugger - Print Associative Array?

Is it possible to "print" or enumerate an associative array in the debugger? If yes, how so?
0 Kudos
6 Replies
RokuMarkn
Level 7

Re: Debugger - Print Associative Array?

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
0 Kudos
EnTerr
Level 8

Re: Debugger - Print Associative Array?

"print" comes to mind Smiley Happy. 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(...)"
0 Kudos
squirreltown
Level 9

Re: Debugger - Print Associative Array?

"EnTerr" wrote:
"print" comes to mind Smiley Happy. 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
Kinetics Screensavers
0 Kudos
pcnweb
Level 7

Re: Debugger - Print Associative Array?

Secondary question: How do I print an associative array in this scenario?

<Component: roArray> =
[
<Component: roAssociativeArray>
]
0 Kudos
pcnweb
Level 7

Re: Debugger - Print Associative Array?

I should pay more attention the answers:

? formatJSON(myVariable)

Does the job, thanks all!
0 Kudos
EnTerr
Level 8

Re: Debugger - Print Associative Array?

"pcnweb" wrote:
Secondary question: How do I print an associative array in this scenario?
<Component: roArray> =
[
<Component: roAssociativeArray>
]

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>

0 Kudos