WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

FileOpen Error 1077 - Capture Additional Error Information


filename = 'c:\temp\badfile.txt'

#DefineFunction OnNextError(wberrorarray)
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]

   ;Get Additional Error Information
   err = StrTrim(ItemExtract( 3, wberrorarray[6], @LF ))
   If IsInt(err)
      EBuff = BinaryAlloc(256)
      BinaryEodSet(EBuff,255)
      If 0 == DllCall(StrCat(DirWindows(1),"Kernel32.dll"),long:"FormatMessageA",long:4096,long:0,long:Err,long:0,lpbinary:EBuff,long:256,long:0)
          msg = StrCat("Error #",Err)
      Else
          msg = BinaryPeekStr(EBuff,0,256)
      EndIf
      BinaryFree(EBuff)
  Else
      msg = err
  EndIf

   errstr = StrCat("Number: ", lasterr, @LF, "String: ", textstring, @LF, "Line (",linenumber,"): '", handlerline, "'", @LF, "Additional Info: ", msg )
   Message("Error Information",errstr)
   Return(1) ; Re-arm error handler
#EndFunction



;IntControl(73,3,0,"OnNextError",0); Arm error handler

handle = FileOpen( filename, "READ")

If handle != @FALSE Then Pause( 'Notice',  'Succcessfully Opened the File' )
FileClose( handle )
Exit

Article ID:   W17871
Filename:   FileOpen Error 1077 - Capture Additional Error Information.txt
File Created: 2008:11:25:12:44:44
Last Updated: 2008:11:25:12:44:44