2 Replies Latest reply on Jun 11, 2014 6:50 AM by Larr

    (10059) Error occurred during file operation

    Larr

      I'm getting the following error message from the SAX Basic Engine, when attempting to execute the GET line of code.

       

      (10059) Error occurred during file operation

       

       

       

      Dim lenToTPN As Integer

      Dim MyPartLen As Integer

      TPN = String(5," ")

      Dim ComponentCompare As String

      Dim fileText As String

       

      sub main

       

      index = 0

      For Each nextComp In ActiveDocument.Components

      ListComps$(index) = nextComp.Name

      index = index + 1

      ComponentCompare=nextComp.PartType

      MyPartLen=Len(ComponentCompare)

      Rem start my special code stuff

      CharPos=InStrRev(FileText, ComponentCompare)

      lenToTPN= CharPos+MyPartLen+1

      Open "C:\Larry\test\schtest\test\67835-0.asc" For Binary  As #1

      Get #1, lenToTPN, TPN

      Close   

       

      end sub

       

        I'm trying to get the next 5 characters from the file, that follow the location of lenToTPN variable, should be the location of the 5 characters that I want to read into the String variable TPN.  Please see attached screen shots of debugger screen.

        Any help, suggestions is appricated,

       

      Thanks in advance,.

       

       

       

       

      67835-0.asc

      !PADS-POWERPCB-V3.0-MILS! DESIGN DATABASE ASCII FILE 2.0

      *PART*

      D1 DO15 61834

      *SIGNAL* N1389173

      R6.2 C2.1

      *END*

        • 1. Re: (10059) Error occurred during file operation
          Patrick.Cashman

          I am not familiar with some of the syntax of your code, and I don't quite follow the logic of it either. But I'll tell you how I do a similar thing and perhaps you can glean something useful from it.

           

          First off I use vb.net and most often the Sharp Develop IDE.  I find it most versatile and powerful, being able to connect to any of the Mentor tools in the Expedition tool set, and having many built-in features that enable complex programming.

           

          In any project I create, I add a file-open and file-save dialog.  I add these to the main form so that they are available universally.  Then I have a read_file function.  I set it up to return an arraylist, with each line of the file as an element in the arraylist. The open_file function looks like this:

           

          Public Function read_file(title As String, file as String) as arraylist

              Dim file_data As New ArrayList

              'this part launches the Open File dialog

              if file = "" then

                  Main_Form.dlg_open.Title = title

                  Main_Form.dlg_open.FileName = ""

                  file = ""

                  if Main_Form.dlg_open.ShowDialog() = dialogresult.OK then

                      file = Main_Form.dlg_open.FileName

                  End If

              end if

           

              'this part reads the file

              file_data.Clear

              Using reader as System.IO.StreamReader = new System.Io.StreamReader(file)

                  while reader.Peek <> -1

                      file_data.add(reader.ReadLine)

                  End While

              End Using

           

              Return file_data

          End Function

           

           

          From any other subroutine in the project, I use the following to create an arraylist and read the file into it:

           

          'declare the arraylist

          Dim data As New ArrayList

           

          'make sure the file exists

          If Not system.IO.File.Exists(open_file_path) Then

              tmp = tmp & "There is no " & open_file_path & ". Please try again."

              msgbox(tmp)

              me.Close

          End If

           

          'make sure the arraylist is empty, then read the file into it

          data.Clear

          data = read_file("", open_file_path)

           

           

          Now to find something in that file data, I do something like this:

           

          For n = 0 to data.count - 1

               If instr(data(n), "stuff to find") > 0 then

                    'do whatever you want with the string

                    'etc

               End if

          Next

           

           

          If your compiler does not support a thing like an arraylist, you could alternatively use an array.  I find the arraylist easier because you don't have to ever resize it or know ahead of time how big it needs to be.  A little less clumsy to me than normal arrays. For many such reasons, I prefer the vb.net language and the free IDE's that are available for it.

           

          By the way, these methods are very fast.  I have used them on files of several hundred thousand lines, and gotten the correct data out in a second or two.

           

          Hope this helps,

           

          Patrick

          • 2. Re: (10059) Error occurred during file operation
            Larr

            Thanks for your assistances,  It lead me down a different path to the soultion.

             

            I was successfully able to read the file into a varible as follows. I'm not sure why I had to use the Input with a "$" dollar sign. none of the documetation shows it being done like this. I think the dollar sign indicates a pointer to the file location, but not sure. Although,  It does work perfectly.

             

            ' if error occurs during open file process, it will generate a runtime error and control is passed to the error handler code.

            On Error GoTo ErrorHandler

            ' open file specified by user input. The file is read into the variable, which is used in the rest of the program.

            Open dlg.PathAndNetlistFileName For Input As #1

            FileText=Input$(LOF(1),1)

            Close

             

             

            ErrorHandler:

            MsgBox "File I/O error.  File does not exist, or path to file is not correct please try again."

            GoTo OpenFile