Hello dans!
Modal forms are an exception to stay in scope themselves, but their click events also end and private or local variables created in their events or methods are also released when these methods end.
Private variables you create in the init of a modal form also release, just the form itself keeps the call stack frozen on its call like the stack is frozen on a READ EVENTS line (as long as no event happens) and further code running is running in the next stack level.
The concept of PRIVATE variables is a bit complicated to understand. On the one side they behave like local variables from the point of view of the call stack level they arre created in, because they release when this call stack level ends. On the other side they behave like global variables on the inside, called code also can see them. That makes them something inbetween local and public. I think they once were invented as some kind of private properties before the OOP concept was added to the language. The idea is their scope is still limited, they only bleed in to further call levels, and since you know and control what you call this has some privacy to them, they release when code return to the calling code which is what controls you, is the outside and therefore again they are private and unseen by the outside from the perspective of calling something means it's inside and being called means that's the outside.
From the perspective of the main.prg every code is inside and so a variable created there is private to all code executed, which has the same effect as public for that special case. The outside is what called main.prg, and that is nothing, at least nothing VFP related (but the stub exe code starting the VFP runtime and starting execution with main.prg). You could anly say the outside is the OS starting the VFP EXE.
PUBLIC variables are also seen inside your whole code. The only difference of explicitly declaring PUBLIC variables is, they are not linked to the call stack level they are created in, even if you create them in code called from code called from main, they stay in scope until the EXE ends or you explicitly RELEASE them.
Bye, Olaf.