Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.
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