How to view more than 9 entries in an array in debug?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BevanFindlay

I am using arrays to store data at runtime, and frequently have to debug data-related issues, but the debugger will only show the first 9 entries in an array, regardless of how big it is. This is really frustrating, as often the problem value is not in that first few entries, but I have not been able to find anything that tells me how else to show more. Seeing as some things are generated randomly, re-running the project with a print() statement or similar isn’t guaranteed to find the problem.

Alternatively, is there a way to watch a variable and break if it is set to a particular value? (And would this work with the contents of a dictionary or a specific item in an array?)

Thanks in advance.

you could do a break down and print individual elements of an array.

assuming you have :

array = ["test", "test2", "test3"]

Then:

for n in array:
 print(n)
 if n=="test2":
  print("..found")

Output:

test
test2
..found
test3

bloodsign | 2021-03-17 11:29

Have you ran the project and looked at the nodes in real time, i.e. clicked on “Remote” in the Scene dock? This may help you to view the contents of the array in real time.

Ertain | 2021-03-17 14:41

This still gets me to the same place, i.e. only showing the first 9 entries in an array.

BevanFindlay | 2021-03-18 06:01

Then the issue probably lies elsewhere.
If printing the elements of the array one by one only leads to 9 elements and checking the nodes in real time says that the array has only 9 elements, then there’s probably only 9 elements in the array.

the for n in array statement should always allow you to iterate to every element in the array. Also as suggested by @Ertain, looking at the [Remote] scene tree should allow you to view real time what is happening to your array. If you click on the relevant node that holds the array, the [Inspector] tab should give you information regarding the array under the [Members] section. From there you’ll see your array and it’s number of elements. Clicking that specific array, should expand it to allow you to view the values it contains.

It would help if you could post a snippet of your code. It’s hard to guess why there’s only 9 elements.

Edit:
PS: If your array has more than 10 elements, you’ll see another entry called “Page”,
where Page 0 shows the 0-9 elements, Page 1 shows 10-19 elements, etc…

bloodsign | 2021-03-18 06:50

The only other option I can think of is writing the contents of the array to a file, and examining that. If the array is too large to use a simple print() function (i.e. print(the_array), and the debugger panel can’t fit the array, then writing the file seems to be the best option.

Ertain | 2021-03-18 06:54

The “Page” option was the answer I was looking for. Thank you. If you repost that part of your comment as an answer, I can mark it as the solution. :slight_smile:

I am wondering if it’s worth putting in an enhancement request to suggest having an easier way to debug large arrays and dictionaries…

BevanFindlay | 2021-03-18 21:04

:bust_in_silhouette: Reply From: Inces

Just look at the console window behind your editor :). You know, this small, black console which opens before and alongside with Godot. It works the same as in-editor console, but prints full content, it is never overloaded by text.

Alternatively You can slow down text output :

for entry in array :
     yield(get_tree().create_timer(0.1),"completed")
     print(entry)

This doesn’t really answer the problem though: yes, I could print( ) and read through some output to find the bit I want, but it’s still going to be awful for large arrays – and I have to go back through and add a print( ) statement somewhere; I can’t do this interactive live while debugging. What I was hoping for was a way to view arrays like how they show in the debugger, but with more than just the first 9 entries.

BevanFindlay | 2021-03-18 06:05

But the big debugger can fit more than 9 entries, just minimalize editor and see it in the other window. You know, when you open editor exe file 2 programs are opened - editor itself and additional console window. If You don’t want to print in process, you can always print on input event

Inces | 2021-03-18 08:44