Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / TPF Constructor & Deconstructor

Author
Message
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Jul 2003 14:19
for a while i've been making my DLLs without using these because quite frankly i'm not entirely sure what i'm suppose to do with them...

so just a quick question, do they get run automatically in DBP?
i mean when you start they run the constructor and when it stops it runs the deconstructor?
its just there must be a reason they're there
http://members.lycos.co.uk/timesaga/p.gif[/img]
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th Jul 2003 14:40
Contructor automatically gets called as soon as the DLL has been loaded (ie. when the app starts) The Destructor function is called just before the DLL is unloaded (when the app closes). They are called automatically if they exist.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 10th Jul 2003 14:42
oki cool... means i can shove some stuff in each and not have to worry about having to call them on exit

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 10th Jul 2003 17:51
I always unallocate memory in the destructor, and generally add a user command to do the same thing. That way, if the user forgets to unallocate memory, the plug-in would be able to unallocate most (if not all of it).

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Jul 2003 22:12
If the code I'm using doesn't need access to DBPro, my construction code is wrapped into a static object that gets run when the DLL loads.

If it does need to access DBPro, the code gets put into the ReceiveCoreDataPtr function, which gets called *immediately* after the Constructor function anyway.

I use the objects destructor to free resources and memory, unless the resource needs to be freed before DBPro exits, when I use the Destructor function.

Basically, I try and wrap all my code into objects that manage themselves, and only intervene when absolutely necessary.

Login to post a reply

Server time is: 2026-07-18 12:57:17
Your offset time is: 2026-07-18 12:57:17