Page 1 of 1

Interrupting a task - how to?

Posted: Thu Mar 11, 2004 9:08 am
by yaccri
I want to control drapes. That requires closing a contact (using an rs232 digital IO unit), sleeping enough time (15 seconds) and releasing the contact.



In order to be able to interrupt that action, I created vb scripts for UP, DOWN and STOP. Each script changes the others' device's state to "stopped" to interrupt the other tasks in case they are running.



IS IT OK TO CHANGE A SCRIPT DEVICE'S STATE TO "STOPPED"?



After making several interrupts, I get error messages on the HB server:

unable to load the script file [my script file]. Error=[The operation completed successfuly].

Unable to compile the script.



After a few more interrupts, the server crashes with error:

AppName: housebotserver.exe AppVer: 2.0.0.0 modName: ntdll.dll

ModVer: 5.1.2600.1217 Offset: 00019ecd



Any suggestions on how else to interrupt tasks or to fix the problem?



Thanks,

Yoram

Re: Interrupting a task - how to?

Posted: Thu Mar 11, 2004 10:10 am
by ScottBot
yaccri wrote:IS IT OK TO CHANGE A SCRIPT DEVICE'S STATE TO "STOPPED"?


Yes... well it should be. Another option would be to add a Property to the Script Device that the script will check and abort itself if changed.



If there was a dump file generated, could you send it to me?

Posted: Fri Mar 12, 2004 12:21 pm
by yaccri
Got it done in a different way.



Instead of interrupting the vb script, I created a sleep device and started/stopped it from the vb scripts.



So now the scripts look like:



' =================================

On Error Resume Next



SetPropertyValue "Sleep Timer-Drape.Running", "No"



' close/open contacts here

' ...



' Sleep enough time

SetPropertyValue "Sleep Timer-Drape.Running", "Yes"



Do While True

If (GetPropertyValue("Sleep Timer-Drape.Running") <> "Yes") Then

Exit Do

End If

Loop



' More stuff here

' ...

' =================================





One nice thing about HB (among many others) is that things can be done in different ways.



Scott, I guess that stopping a running vb script manualy may cause crashes.



Yoram.