question

Enrique Elizaga avatar image
1 Like"
Enrique Elizaga asked Matthew Gillespie answered

How do you destroy/delete a variable in debugger?

Hi, Im debugging a code and sometimes you have many variables that you are not using anymore in the middle or ending part of the code. Especially if you arrange by blocks. Can I forget a variable that I am no longer using to only see the ones I want? I have seen that FlexSim does this during the "for" cycles. It uses the counter or index and when the cycle is finished, the variable is not there in the debugger screen anymore.

FlexSim 18.2.2
debugdebuggerdebuggin
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered

The reason the variables in for loops disappear is that they go out of scope. The basic idea being that if a variable is defined within a set of curly braces ( { int x = 0; } ) it can only be used within those curly braces and is forgotten after leaving that set of curly braces. This image from this site is a good example:

Other than correctly scoping your variables, I don't know of any way to delete a variable in the debugger.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.