I have a certain operation in a class that is very expensive. (on the order of about 8 seconds to fully run) So, now I've decided it should probably run at the beginning of the program during an "initialization" screen. I can't find anywhere in Delphi indicating that there is such a thing as a static field however.
What I basically need to do is load a list of records and keep them alive throughout the life of the program. What is the best way to do this in Delphi?
I would do this in C# quite simply:
class Foo{
static List<...> Bar;
}
However in Delphi, I'm not seeing anything for creating a static field. All I see is the class
keyword for creating static methods
You can just use a global variable. Add it in the implementation
section of a unit to make it local to that unit.
My Turbo Delphi supports class var x:integer;
, but I'm pretty sure Delphi 7 doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With