Forum > General

Break and StringLists

(1/2) > >>

I have a program that uses StringLists and declares them at Form.Activate.

However, my program uses special configuration files that will terminate if any errors are found, and when the termination happens, I first Free the StringLists, and then Break. But I don't know if Break will execute the Form.Deactivate part of the program, where I have another copy of the Free commands.

My question simply is: Does Break quit the program without executing Form.Deactivate or not?

Break does not execute anything.
It is simply a syntactical alternative to a goto someLabel instruction, exiting the local (for, while, repeat) loop in which you have placed it.

In that case, it's best if I keep the copy of the Free commands at both the Form.Deactivate and the condition in which the Break is used?

No, Simply use FreeAndNil instead, that will do Free first and then set the pointer to NIL.

Free will test if the pointer is NIL and if so not attempt to free it.

That is one the main reasons FreeAndNil was created..

Also, using Application.Terminate maybe more of what you need.

I'm trying Application.Terminate, seems to be working. Only hope it does Free the StringList memory, last thing I want is memory leaks :)


[0] Message Index

[#] Next page

Go to full version