Download WinBatch User`s Manual - WinBatch Tech Database

Transcript
APPENDIX B: WinBatch+ Compiler
IntControl(38,1,"errorlog.txt",0,0) ;Route errors to log file
EndIf
;Now for the main service loop
;in this service we respond to all control messages
BoxOpen("Initializing","main service loop")
While @TRUE
If DoingDebug==@FALSE
code=SvcWaitForCmd(5000) ;Timeout in 5 seconds
Else
;For Debugging.
;Prompt tester to see what code should be pretended here
code=AskItemlist("Service Debug", debugcodes, "|", @UNSORTED,
@SINGLE)
If code=="" Then Continue
code=ItemExtract(1,code,":")
EndIf
Switch code
Case SERVICE_CONTROL_TIMEOUT
;Timeout occurred
BoxTitle("SERVICE_CONTROL_TIMEOUT")
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GoSub DoWork
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Break
Case SERVICE_CONTROL_STOP
;Stop command received
BoxText("Stop command received")
SvcSetState(SERVICE_STATE_STOP_PENDING)
;do stop cleanup work here
TimeDelay(5)
SvcSetState(SERVICE_STATE_STOPPED)
Exit
;Goodbye
Break
Case SERVICE_CONTROL_PAUSE
;Pause command received
BoxText("Pause command received")
SvcSetState(SERVICE_STATE_PAUSE_PENDING)
;do pause cleanup work here
SvcSetState(SERVICE_STATE_PAUSED)
Break
Case SERVICE_CONTROL_CONTINUE
;Continue command received
BoxText("Continue command received")
SvcSetState(SERVICE_STATE_CONTINUE_PENDING)
;do resume from pause state initialization here
SvcSetState(SERVICE_STATE_RUNNING)
Break
Case SERVICE_CONTROL_SHUTDOWN
;Shutdown notification received
;Approx. 20 seconds to process
BoxText("Shutdown notification received")
SvcSetState(SERVICE_STATE_STOP_PENDING)
131