Loading ...
Sorry, an error occurred while loading the content.

Input Past End of File

Expand Messages
  • John Huffman
    Hello - I have written a short program. It reads a sequential file that is written by other software and then looks up two corresponding values in an array
    Message 1 of 3 , Dec 11, 2012
    • 0 Attachment
      Hello -

      I have written a short program. It reads a sequential file that is
      written by other software and then looks up two corresponding values in
      an array and displays those values. There are times that I get this
      error message - 62 Input past end of file.

      I assume the other software is writing to the same file my program is
      trying to read - both at the same time.

      From my program -
      - - - -
      [reading]
      open "C:\Pegasus\pegasus.out" for input as #rig
      ' read rig
      input #rig, rig
      ' close pegasus.out file
      close #rig

      rig = rig * 1000

      print rig
      ' for x = 0 to data array length
      for x = 0 to z

      ' compare rig to freq(x)
      if int(rig) < freq(x) then

      ' compare rig to freq(x) and to freq(x-1)
      ' to find the closest value in the array
      diffz = freq(x) - rig
      if x > 0 then
      diffzminus = rig - freq(x-1)

      ' if rig - freq(x) is smaller than rig - freq(x-1) then print cap(x)
      and ind(x)
      if diffz < diffzminus then
      print #main.freqtxt, freq(x); " ";
      print #main.captxt, cap(x); " ";
      print #main.indtxt, ind(x)
      exit for
      else
      print #main.freqtxt, freq(x-1); " ";
      print #main.captxt, cap(x-1); " ";
      print #main.indtxt, ind(x-1)
      exit for
      end if
      end if
      next x

      ' timer loop
      timer 2000, [reading]
      scan
      wait
      - - - -
      Is there a way to have my program wait for a bit until the file is
      available?

      73 de K1ESE
      John
    • Rod
      If you always find the file exists and is accessible then simply check that the lof() is about what you expect. So while lof(#file)
      Message 2 of 3 , Dec 11, 2012
      • 0 Attachment
        If you always find the file exists and is accessible then simply check that the lof() is about what you expect. So while lof(#file)<expected wend. This fast loop will be ok after your timed delay and should delay the read till the contents exist. Might be better to check the file is available with the files command as belt and braces.

        --- In libertybasic@yahoogroups.com, John Huffman <hjohnc@...> wrote:
        >
        > Hello -
        >
        > I have written a short program. It reads a sequential file that is
        > written by other software and then looks up two corresponding values in
        > an array and displays those values. There are times that I get this
        > error message - 62 Input past end of file.
        >
        > I assume the other software is writing to the same file my program is
        > trying to read - both at the same time.
        >
        > From my program -
        > - - - -
        > [reading]
        > open "C:\Pegasus\pegasus.out" for input as #rig
        > ' read rig
        > input #rig, rig
        > ' close pegasus.out file
        > close #rig
        >
        > rig = rig * 1000
        >
        > print rig
        > ' for x = 0 to data array length
        > for x = 0 to z
        >
        > ' compare rig to freq(x)
        > if int(rig) < freq(x) then
        >
        > ' compare rig to freq(x) and to freq(x-1)
        > ' to find the closest value in the array
        > diffz = freq(x) - rig
        > if x > 0 then
        > diffzminus = rig - freq(x-1)
        >
        > ' if rig - freq(x) is smaller than rig - freq(x-1) then print cap(x)
        > and ind(x)
        > if diffz < diffzminus then
        > print #main.freqtxt, freq(x); " ";
        > print #main.captxt, cap(x); " ";
        > print #main.indtxt, ind(x)
        > exit for
        > else
        > print #main.freqtxt, freq(x-1); " ";
        > print #main.captxt, cap(x-1); " ";
        > print #main.indtxt, ind(x-1)
        > exit for
        > end if
        > end if
        > next x
        >
        > ' timer loop
        > timer 2000, [reading]
        > scan
        > wait
        > - - - -
        > Is there a way to have my program wait for a bit until the file is
        > available?
        >
        > 73 de K1ESE
        > John
        >
      • John Huffman
        Rod - Thanks for the quick reply. I tried just using the while lof(#file)
        Message 3 of 3 , Dec 11, 2012
        • 0 Attachment
          Rod -

          Thanks for the quick reply.

          I tried just using the "while lof(#file)<expected wend". That worked
          fine, but the problem was back at FileExist. I tried some of the code
          in the documentation for the FileExist function, but would have to study
          it a bit longer to correctly implement it.

          That got me thinking that instead of accessing the data in the file, the
          same data could be retrieved directly from the radio hardware through
          the serial port. A couple of years ago you helped me to put together
          some code to do just that for another application. I replaced the file
          access routine I was using with the serial routine from the other
          program and everything seems to work well and so far no errors.

          I may go back to getting the FileExist up and running, but the instant
          problem seems solved.

          Thanks for the help now and the help from a couple of years ago.

          73 de K1ESE
          John


          On 12/11/2012 2:58 PM, Rod wrote:
          >
          > If you always find the file exists and is accessible then simply check
          > that the lof() is about what you expect. So . This fast loop will be
          > ok after your timed delay and should delay the read till the contents
          > exist. Might be better to check the file is available with the files
          > command as belt and braces.
          >
          > --- In libertybasic@yahoogroups.com
          > <mailto:libertybasic%40yahoogroups.com>, John Huffman <hjohnc@...> wrote:
          > >
          > > Hello -
          > >
          > > I have written a short program. It reads a sequential file that is
          > > written by other software and then looks up two corresponding values in
          > > an array and displays those values. There are times that I get this
          > > error message - 62 Input past end of file.
          > >
          > > I assume the other software is writing to the same file my program is
          > > trying to read - both at the same time.
          > >
          > > From my program -
          > > - - - -
          > > [reading]
          > > open "C:\Pegasus\pegasus.out" for input as #rig
          > > ' read rig
          > > input #rig, rig
          > > ' close pegasus.out file
          > > close #rig
          > >
          > > rig = rig * 1000
          > >
          > > print rig
          > > ' for x = 0 to data array length
          > > for x = 0 to z
          > >
          > > ' compare rig to freq(x)
          > > if int(rig) < freq(x) then
          > >
          > > ' compare rig to freq(x) and to freq(x-1)
          > > ' to find the closest value in the array
          > > diffz = freq(x) - rig
          > > if x > 0 then
          > > diffzminus = rig - freq(x-1)
          > >
          > > ' if rig - freq(x) is smaller than rig - freq(x-1) then print cap(x)
          > > and ind(x)
          > > if diffz < diffzminus then
          > > print #main.freqtxt, freq(x); " ";
          > > print #main.captxt, cap(x); " ";
          > > print #main.indtxt, ind(x)
          > > exit for
          > > else
          > > print #main.freqtxt, freq(x-1); " ";
          > > print #main.captxt, cap(x-1); " ";
          > > print #main.indtxt, ind(x-1)
          > > exit for
          > > end if
          > > end if
          > > next x
          > >
          > > ' timer loop
          > > timer 2000, [reading]
          > > scan
          > > wait
          > > - - - -
          > > Is there a way to have my program wait for a bit until the file is
          > > available?
          > >
          > > 73 de K1ESE
          > > John
          > >
          >
          >



          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.