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

File Access Question

Expand Messages
  • John
    I m using liberty basic to read the serial port and then dump what it read to a text file. However, the text file is being read by excel so some number
    Message 1 of 5 , May 1, 2006
    • 0 Attachment
      I'm using liberty basic to read the serial port and then dump what it
      read to a text file. However, the text file is being read by excel so
      some number crunching could be done on data. Now the problem is the
      text file doesn't get updated until it is closed. Is there a way to
      force it to dump the stuff to file other than closing the file and
      reopening it?

      open "C:\data.txt" for append as #datafile

      'while lof(#comm)<4
      ' scan
      'wend
      t$ = input$(#comm, lof(#comm)) 'Get com port data
      if t$ <> "" then print #datafile, t$; 'Display com port data
      close #datafile
      scan 'Check for input events

      It writes the data but now it seems like if excel tries to refresh
      the data while the file is closed in liberty basic it creates a
      locking problem and liberty basic errors.

      Any help would be appreciated

      Timoahm
    • Fritz Oppliger
      Looks like your OPEN statement is outside the loop?
      Message 2 of 5 , May 1, 2006
      • 0 Attachment
        Looks like your OPEN statement is outside the loop?

        On Mon, 01 May 2006 06:31:17 -0700, John <timoahm@...> wrote:

        > I'm using liberty basic to read the serial port and then dump what it
        > read to a text file. However, the text file is being read by excel so
        > some number crunching could be done on data. Now the problem is the
        > text file doesn't get updated until it is closed. Is there a way to
        > force it to dump the stuff to file other than closing the file and
        > reopening it?
        >
        > open "C:\data.txt" for append as #datafile
        >
        > 'while lof(#comm)<4
        > ' scan
        > 'wend
        > t$ = input$(#comm, lof(#comm)) 'Get com port data
        > if t$ <> "" then print #datafile, t$; 'Display com port data
        > close #datafile
        > scan 'Check for input events
        >
        > It writes the data but now it seems like if excel tries to refresh
        > the data while the file is closed in liberty basic it creates a
        > locking problem and liberty basic errors.
        >
        > Any help would be appreciated
        >
        > Timoahm
        >
        >
        >
        >
        >
        > YAHOO! GROUPS LINKS
        >
        > Visit your group "libertybasic" on the web.
        >
        > To unsubscribe from this group, send an email to:
        > libertybasic-unsubscribe@yahoogroups.com
        >
        > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >
        >
      • John
        Its not its all one big loop [loop] open C: data.txt for append as #datafile while lof(#comm)
        Message 3 of 5 , May 1, 2006
        • 0 Attachment
          Its not its all one big loop

          [loop]
          open "C:\data.txt" for append as #datafile
          'while lof(#comm)<4
          ' scan
          'wend
          t$ = input$(#comm, lof(#comm)) 'Get com port data
          if t$ <> "" then print #datafile, t$; 'Display com port data
          close #datafile
          scan 'Check for input events
          goto [loop]

          I'm just trying to figure out if there is a way to flush the file
          stream without closing the file.


          --- In libertybasic@yahoogroups.com, "Fritz Oppliger" <fritzo2@...>
          wrote:
          >
          >
          > Looks like your OPEN statement is outside the loop?
          >
        • John
          No, it all happens inside a loop [loop] open C: data.txt for append as #datafile while lof(#comm)
          Message 4 of 5 , May 1, 2006
          • 0 Attachment
            No, it all happens inside a loop
            [loop]
            open "C:\data.txt" for append as #datafile
            'while lof(#comm)<4
            ' scan
            'wend
            t$ = input$(#comm, lof(#comm)) 'Get com port data
            if t$ <> "" then print #datafile, t$; 'Display com port data
            close #datafile
            scan 'Check for input events
            goto [loop]

            I'm just wanting a way to force the datastream to flush to file
            without closing the file constantly since it causes locking issues
            with excel.



            --- In libertybasic@yahoogroups.com, "Fritz Oppliger" <fritzo2@...>
            wrote:
            >
            >
            > Looks like your OPEN statement is outside the loop?
          • pendl2megabit
            Message 5 of 5 , May 2, 2006
            • 0 Attachment
              >
              > Its not its all one big loop
              >
              > [loop]
              > open "C:\data.txt" for append as #datafile
              > 'while lof(#comm)<4
              > ' scan
              > 'wend
              > t$ = input$(#comm, lof(#comm)) 'Get com port data
              > if t$ <> "" then print #datafile, t$; 'Display com port data
              > close #datafile
              > scan 'Check for input events
              > goto [loop]
              >
              > I'm just trying to figure out if there is a way to flush the file
              > stream without closing the file.

              Sorry, but no flushing for files with LB native code.

              You can still use API functions to open the file, which will enable you to
              flush the buffer.

              ---
              Stefan Pendl






              ___________________________________________________________
              Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
            Your message has been successfully submitted and would be delivered to recipients shortly.