View Full Version : How to stop script execution?
Michael Hartlef
05-05-2007, 07:17
Hi folks,
I need to stop script execution. We have the STOP command, but that doesn't allways do his job. Is there a reliable way to stop the execution from within the script?
Michael
ErosOlmi
05-05-2007, 07:31
STOP try to end script in a controlled way terminating all internal Core loops. It is true that it cannot work in all situation especially if loop is inside a script function.
See if the attached thinCore.dll make any difference.
Eros
PS. Attached removed. Out of date.
Michael Hartlef
05-05-2007, 07:43
Will try this. Thanks!
ErosOlmi
05-05-2007, 09:11
OK, fine. Please let me know if it works.
Mainly I've generated an internal fake runtime error when STOP keyword is encountered in main script or inside function body.
This should stop all activities even if inside nested loops.
Attention. If you use functionality that needs to be released, like linked lists or dictionaries, it is programmer responsability to release allocated memory.
While this is not a problem under Win NT class OSs like Win2K, WinXp or above, it can get nasty problems under 16bit OSs like WinME or Win98
Ciao
Eros
Michael Hartlef
05-05-2007, 09:17
Ok, you gave a perfect reason to leave it like it is.
Because I have to do some garbage collection.
ErosOlmi
05-05-2007, 10:32
Maybe you can create your own stop function.
function MyStop()
'---Release all things to be released
'...
'---
STOP
end function
'...When needed ...
if NeedToStop = %TRUE then
MyStop
end if
Michael Hartlef
06-05-2007, 16:37
Naah, to much work. I guess it is more a matter of getting used to the limitations of thinBasic.
ErosOlmi
06-05-2007, 16:40
Mike, sorry I do not understand your reply.
Did you test attached new thinCore.dll? I've made a change that should end execution as soon as a STOP is encountered.
Michael Hartlef
06-05-2007, 16:50
No, as you are right. Garbage collection has to be done anyway, so a full jump out of the script isn't good at all.
RobertoBianchi
07-05-2007, 09:16
Eros,
why not simulate a run-time erron or an exception in order to stop?
Ciao,
Roberto
ErosOlmi
07-05-2007, 09:51
Yes. It is what I did in current online preview release. So we had the same idea.
STOP keyword will generate an internal fake RunTime error stopping internal parsing chain.
In any case the problem of deallocation of user allocated strutcures like linked lists and dictionaries will remain.
Ciao
Eros