Script Control Reset

SystemOfADown
06-05-2005, 01:11 PM
Hello.
I have a script control in my project, and I have it set to be reset when the user does a certain thing. The problem is, the script may be in the middle of executing something when this happens. Other times, I want the script to call a sub inside the program to terminate the script itself. The problem with both of these things, is that the script is "executing" and so vb gets mad when you try to do this. Is there any way to force a reset, and just stop the script and unload it from memory?

Thanks in advance.

SystemOfADown
06-11-2005, 08:35 AM
Hmm...
Is this not possible?

Rockoon
06-11-2005, 01:31 PM
Hello.
I have a script control in my project, and I have it set to be reset when the user does a certain thing. The problem is, the script may be in the middle of executing something when this happens. Other times, I want the script to call a sub inside the program to terminate the script itself. The problem with both of these things, is that the script is "executing" and so vb gets mad when you try to do this. Is there any way to force a reset, and just stop the script and unload it from memory?

Thanks in advance.

My experience with using the eval() function to kick start the script into running is that your thread is given to the script control. Basically, your program is paused until eval() returns.

..A fix for this is to provide a VB function to your script which issues DoEvents. That allows you to go so far as to at least know when the user 'does something' by giving your VB thread event handler a chance to execute. You can provide such a function by giving the script control a reference to a COM object (any VB class instance will do)

I'm assuming, although I am not sure.. that you cannot safely destroy the script object from within this called function. I'm assuming you will crash your application. However you can probably set a property of that COM object that indicates that its time for the script to end.

The script can then check this flag at regular intervals and exit out when needed.

If its a general purpose script executioner, meaning that the scripts arent going to be designed with this functionality in mind, then you can still insert code into the script automatically to do this for you.

If the scripts arent designed to be eval() bootstrapped, you can also automatically alter the script to wrap all module-level code up into a function that CAN be launched with eval().. however this sounds a little tedius.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum