forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Initialize and Terminate Events for DSU

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Wish List
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Tue Sep 02, 2003 12:30 pm    Post subject: Initialize and Terminate Events for DSU Reply with quote

Initialize and Terminate Events for DSU

Having a Initialize and terminate events for a DSU/include file can be very helpful.
These events will be called automatically on loading/unloading the dll.

Especially with API use where one can avoid the mess of user having to call these events for initializing a dll and cleanup events more so when they are not simple.
This avoids e.g. user forgetting to call the dll unload function.

What most of us do is trashing with the dll by repeated load unload inside the dsu Smile

It is also useful to show a demo dialog for shreware DSU at startup rather than showing it up with each function or each time a function is called.

One may suggest a work around for all these but that would be more convenient I think.
Useful or stupid idea Rolling Eyes

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Tue Sep 02, 2003 12:51 pm    Post subject: Reply with quote

I think you should do somthing like this...

Code:
:Exit
dsufile unload
exit


You can't send all DSU files a 'terminate' event, because they basicly are just subroutines of the whole script...

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Tue Sep 02, 2003 1:07 pm    Post subject: Reply with quote

Quote:
You can't send all DSU files a 'terminate' event, because they basicly are just subroutines of the whole script...


Indeed. When the VDS runtime executes the compiled script, it doesn't have a clue whether the code came from multiple dsc files, dsu files or one humungous dsc.

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Sep 12, 2003 5:47 am    Post subject: Reply with quote

I do understand that a DSU is just compiled into one plain sheet of code and is executed in the same way as a single .dsc file. What I was talking was something like this:

At present I think this is how an include file/.dsu is added to a compiled script (I am only Imagining things here but it may be moslty correct)

Code:
<--------------Script Begin-------------------->

<-----Define complier instructions----->
#Define command1
#Define function1
etc
<---End of Define instructions-->

<----.DSC file code begin--->
CODE
CODE

:EVLOOP
WAIT EVENT()
GOTO @EVENT()

:SUB1
GOTO EVLOOP
Blah
<----.DSC file code end--->


<----DSU code Begin--->

WARN This is a demo version of my DSU

:First command
CODE
CODE
Blah
Exit

:secondcommand
CODE
CODE
Blah
Exit

<--DSU code End--->

<--------------Script end--------------------->



As one can see in the above the code:
Code:
WARN This is a demo version of my DSU

is not executed since it is added below the :EVLOOP

What I was requesting was a ability to give a compiler directive to add the code between a tag eg #INITCODE #ENDINITCODE to the TOP before the :EVLOOP in the complied script so that it can be executed the moment the dsu is included. This can be used for other functions also like LOADLIB etc.

Similarly a close label :CLOSE#1 :CLOSE#2 etc to be looked for and executed if present before the exe quits.

This can be useful for unloading DLLs, releasing Device Contexts, closing open handles to files objects bitmaps etc WITHOUT RELYING on end user intervention. Else if he forgets* to call a close command cleanup is not done and undesirable consequences may occur bringing bad name to DSU author.

* I understand the responsibilty of end user but I think a programmer should always consider the end user to be kinda moron etc to be on safer side.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Sep 12, 2003 8:19 am    Post subject: Reply with quote

It's important for debugging that the line numbers in the compiled script correspond to lines in the original source files. So having the compiler insert bits of code within another file isn't practical. I think this whole thing would be better done by just having functions within your dsu that you have to call at startup and finish. It might seem harder but I think to the novice it's actually more understandable as they can see from the code what's going on, instead of having code being executed that is being called because of some directive somewhere else in the program entirely.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Sep 12, 2003 2:18 pm    Post subject: Reply with quote

jules wrote:
It's important for debugging that the line numbers in the compiled script correspond to lines in the original source files.


Embarassed I didn't think about debugging aspect. It is not absloutely necessary to have such a thing although I thought that it would make the DSU more self reliant.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group