Page 1 of 1

Multiple conditions in Routine

Posted: Wed Oct 08, 2014 1:37 pm
by Developer9
Hi Gurus ,

How do i write multiple conditions in a routine? i need it like mentioned below , but i am getting compile errors when i do it like this. I tried putting all 3 conditions in brackets , tried comma , semicolon at the end still gives compile errors.

Code: Select all

 If Status = DSJS.RUNFAILED  Then
    ErrCode = DSRunJob(JobHandle, DSJ.RUNRESET) 
    ErrCode = DSDetachJob(JobHandle)  
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
ELSE 
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
Compile Error :
0054 ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL) ELSE

^
"ELSEEOL" unexpected, Was expecting: ';', End of Line

Posted: Wed Oct 08, 2014 3:00 pm
by chulett
Dang... been a long time but try:

Code: Select all

If Status = DSJS.RUNFAILED  Then 
    ErrCode = DSRunJob(JobHandle, DSJ.RUNRESET) 
    ErrCode = DSDetachJob(JobHandle)  
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL) 
END ELSE 
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
END

Posted: Wed Oct 08, 2014 3:16 pm
by ray.wurlod
Despite it being a long time, Craig has correctly remembered the "multi-line" or "block" format. The block of statements needs to be terminated with an End statement.

You won't be able to run a detached job.

I prefer initial capitals to all upper case, though keywords in the BASIC language are case insensitive.

Code: Select all

If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED  
Then 
    ErrCode = DSRunJob(JobHandle, DSJ.RUNRESET) 
    ErrCode = DSDetachJob(JobHandle)  
    JobHandle = DSAttachJob(JobName, DSJ.ERRNONE)
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL) 
End
Else
    ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL) 
End

Posted: Wed Oct 08, 2014 3:24 pm
by chulett
Yay me! :D

Sorry, didn't even look at the actual code for sense making.

Posted: Thu Oct 09, 2014 8:29 am
by Developer9
You guys Rock ....

Thanks