WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: George Vagenas on June 23, 2013, 04:29:58 PM

Title: 1028: Logdisk: Requested drive not on line
Post by: George Vagenas on June 23, 2013, 04:29:58 PM
Apart from closing any Explorer windows accessing the drive is there any way to recover from this error?
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 24, 2013, 07:55:44 AM
You could try adding a DirChange just before the offending function, to ensure your script isn't logged into that directory. If that doesn't help resolve the issue please post a code snippet of the code you are having a problem with. DebugTrace output might also be useful.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: George Vagenas on June 25, 2013, 03:23:26 AM
This is a snippet of the code that caused the error, but I had run it several times the other day without incident.  And I just ran i t several times now, again without any problem.  I did modify the code to see if a DirChange when logged into the directory caused any problems but it doesn't. 

Code (winbatch) Select

Root = wingetactive()
if strindexnc(Root, 'powerdesk', 0, @fwdscan)==1
   Ndx = strindex(Root, '>', 0, @fwdscan)
   Root = strsub(Root, Ndx+2, -1)
   Ndx = strindex(Root, '\', 0, @backscan)
   Root = strsub(Root, 1, Ndx)
else
   ; Directory Opus's title is the current folder.
   Root = strcat(wingetactive(), '\')
endif
boxopen('Cover folder', 'Creating/updating Cover folder for ':Root)
dirchange(Root)
; Just a test normally causes no problems.
dirchange(Root)   
Folders = diritemize('*.*')
; Script proceeds to process folders.
display(3, 'No Problem', Root)
:cancel
return


As I said I was looking for a way to recover from the error.  If its not possible then perhaps it should be assigned a severe error level.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 25, 2013, 08:11:12 AM
Sorry I didn't realize you were asking about error handling. In that case we have a nice tutorial that should help: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+Tutorials+Trap~Errors.txt

The easiest option is to use ErrorMode around the offending function to capture this specific error:
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 25, 2013, 08:14:20 AM
I see you are using WinGetActive then passing the results to a DirChange function. Yet I do not see any code to confirm that you have a valid directory. I recommend adding code to confirm you have a valid directory name before passing it to any function that accepts a directory path. See DirExist.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: George Vagenas on June 25, 2013, 04:53:54 PM
These lines process WingetActive to return valid folders. Normally I use Directory Opus and its window title is always the logged folder.
Code (winbatch) Select

      if strindexnc(Root, 'powerdesk', 0, @fwdscan)==1
         Ndx = strindex(Root, '>', 0, @fwdscan)
         Root = strsub(Root, Ndx+2, -1)
         Ndx = strindex(Root, '\', 0, @backscan)
         Root = strsub(Root, 1, Ndx)
      else
         Root = strcat(wingetactive(), '\')
      endif


As for error handling this is my error handling template.
Code (winbatch) Select

   intcontrol(73, 2, 0, 0, 0)   ; GOSUB error handler.

:WBERRORHANDLER
   Error = LastError()
   
;    if Error==####
;       ; Deal with it.
;       intcontrol(73, 2, 0, 0, 0)   ; GOSUB error handler.
;       return
;    endif
   
   ErrInfo = strcat('Error: #', Error, ': ', wberrortextstring, @crlf, 'Script: ', wberrorhandlerline, @crlf, 'Assignment: ', wberrorhandlerassignment, @crlf, 'File: ', wberrorhandlerfile, @crlf, 'Procedure: ', wberrorinsegment, @crlf, 'Line No. ', wberrorhandlerlinenumber, @crlf)
   clipput(ErrInfo)
   pause('Error Message on Clipboard', ErrInfo)

   exit


And what I'm looking for is the code that I could insert here:
Code (winbatch) Select

   if Error==1028
      ; Deal with it.
      ...
      intcontrol(73, 2, 0, 0, 0)   ; GOSUB error handler.
      return
   endif
   

to recover from the error.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 26, 2013, 07:40:25 AM
As for using WinGetActive, This function merely obtains the current active Window Title. Consider an instance where the expected application is not running or not active. I recommend avoiding such an issue by checking if the directory in fact exists. See DirExist.

I see you already have error handling built into the script. All you will need to do is add the code to the :WBERRORHANDLER to handle this specific error number. I see you are already calling LastError() in the WBERRORHANDLER. This function call will return 1028. I see you have also already added code to capture that specific error. Since you want to simply ignore the error you should re-arm the error handle and return ( just as you have. )

What is it you would like to do? Add additional code to re attempt the command? If so then add this code inside this if condition.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: George Vagenas on June 26, 2013, 01:51:11 PM
"As for using WinGetActive, This function merely obtains the current active Window Title. Consider an instance where the expected application is not running or not active. I recommend avoiding such an issue by checking if the directory in fact exists. See DirExist."

I'm sorry I thought  it was clear that I am launching the code with either Directory Opus or Power Desk as the active window (from Popmeunu with a hot-key actually).  Hence the initial code to get the current (root) folder using WinGetActive.

"I see you already have error handling built into the script."  No I don't, I posted my Error template in response to your suggestion that I use Error mode.

"What is it you would like to do? Add additional code to re attempt the command? If so then add this code inside this if condition." 

Again I thought this was clear, but what code should I add to recover from this error?  As I said in my original post:
"Apart from closing any Explorer windows accessing the drive is there any way to recover from this error?"
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 26, 2013, 02:21:12 PM
Lots of miscommunication going on in this thread....

Maybe a Full code sample will help:

Code (winbatch) Select

Root = WinGetActive()
if strindexnc(Root, 'powerdesk', 0, @fwdscan)==1
   Ndx = strindex(Root, '>', 0, @fwdscan)
   Root = strsub(Root, Ndx+2, -1)
   Ndx = strindex(Root, '\', 0, @backscan)
   Root = strsub(Root, 1, Ndx)
else
   ; Directory Opus's title is the current folder.
   Root = strcat(Root, '\')
endif

If !DirExist( Root )
    Pause('Notice', 'Current active window did seem to be a valid directory:':@lf:Root)
    Exit
Endif

BoxOpen('Cover folder', 'Creating/updating Cover folder for ':Root)

DirChange(Root)
 
Folders = DirItemize(Root:'*.*')
; Script proceeds to process folders.
Display(3, 'No Problem', Root)

Exit

:WBERRORHANDLER
Error = LastError()
   
If Error == 1028 ; Handle LogDisk Error
   Root = WinGetActive()
   DirChange('C:\')
   IntControl (73, 2, 0, 0, 0)   ; Re-Arm error handler.
   Return
Endif

ErrInfo = strcat('Error: #', Error, ': ', wberrortextstring, @crlf, 'Script: ', wberrorhandlerline, @crlf, 'Assignment: ', wberrorhandlerassignment, @crlf, 'File: ', wberrorhandlerfile, @crlf, 'Procedure: ', wberrorinsegment, @crlf, 'Line No. ', wberrorhandlerlinenumber, @crlf)
Pause('Error Message on Clipboard', ErrInfo)
Exit


I hope this helps.
Title: Re: 1028: Logdisk: Requested drive not on line
Post by: George Vagenas on June 27, 2013, 01:58:51 AM
Thanks for the input but given that this error is intermittent I decided that I can live with the occasional restart of Opus or PowerDesk.  Also I was able to test the script to make sure the error routine works as expected. 
Code (winbatch) Select

:WBERRORHANDLER
   Error = LastError()
   
   if Error==1028
      ; Deal with it.
      winclose(wingetactive())
      gosub CreateCoverFolder
     
      if Powerdesk      ; True if PowerDesk was the active window.
         run("C:\Program Files\Avanquest\PowerDesk\PDExplo.exe", '"':Root:'"')
      else
         run("C:\Program Files\GPSoftware\Directory Opus\dopus.exe", '"':Root:'"')
      endif   
      exit
   endif
   
   ErrInfo = strcat('Error: #', Error, ': ', wberrortextstring, @crlf, 'Script: ', wberrorhandlerline, @crlf, 'Assignment: ', wberrorhandlerassignment, @crlf, 'File: ', wberrorhandlerfile, @crlf, 'Procedure: ', wberrorinsegment, @crlf, 'Line No. ', wberrorhandlerlinenumber, @crlf)
   clipput(ErrInfo)
   pause('Error Message on Clipboard', ErrInfo)

   exit

Title: Re: 1028: Logdisk: Requested drive not on line
Post by: Deana on June 27, 2013, 07:58:39 AM
Happy to hear you found a solution that fits your needs.