View previous topic :: View next topic |
Author |
Message |
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Tue Sep 02, 2003 12:30 pm Post subject: Initialize and Terminate Events for DSU |
|
|
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
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 _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Tue Sep 02, 2003 1:07 pm Post subject: |
|
|
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 |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Sep 12, 2003 5:47 am Post subject: |
|
|
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
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Sep 12, 2003 8:19 am Post subject: |
|
|
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 |
|
|
CodeScript Moderator Team
Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Fri Sep 12, 2003 2:18 pm Post subject: |
|
|
jules wrote: | It's important for debugging that the line numbers in the compiled script correspond to lines in the original source files. |
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
Give your application a professional look with the VDSGUI Extension |
|
Back to top |
|
|
|