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

Re: [libertybasic] Re: Using variables in creating Random Access Files

Expand Messages
  • POR20@aol.com
    Thanks Janet, I haven t played with binary files. Is this a first in/ first out format - or is this just another form of random access? I ll look at again.
    Message 1 of 7 , Jul 31 9:21 PM
    • 0 Attachment
      Thanks Janet,

      I haven't played with binary files. Is this a "first in/ first out" format -
      or is this just another form of random access? I'll look at again. Thanks
      again for your help.

      Don


      [Non-text portions of this message have been removed]
    • cmcmurchie
      Don, Do you know the structure of Dbase 4 files, or could you post a link to somewhere that explains it? Just guessing, but you should be able to extract
      Message 2 of 7 , Aug 2, 2004
      • 0 Attachment
        Don, Do you know the structure of Dbase 4 files, or could you post a
        link to somewhere that explains it?

        Just guessing, but you should be able to extract record length
        information from the header, and with suitable manipulation, then use
        that to read the data part of the file (you may have to split the
        file). You would at least know when a should be in
        open "c:\test.txt" for random as #1 len = a

        Colin



        --- In libertybasic@yahoogroups.com, "donaldherche" <POR20@a...>
        wrote:
        > I'm a new user trying to convert some routines from QuickBasic.
        > These routines read dbase IV headers and create subsets of the
        > database as random access files. Anyway, I can't seem to use
        > variables for the fielding statements or the Len.
        >
        > For example, this doesn't seem to work:
        >
        > a=1
        > open "c:\test.txt" for random as #1 len = a
        >
        > Changing the "a" in the open statement to a "1" works, but I need
        > this to be determined "on the fly".
        >
        > Also, this doesn't seem to work either:
        >
        > field #1, a as test$
        >
        > Again, changing the "a" to a "1" works fine, but this value has to
        > changes depending on the original dbase structure or the subset
        that
        > needs to be constructed.
        >
        > I've never worked with tsunami or anything other than the old
        dbase.
        > Is this where I'm heading, or is there someway to make this work
        the
        > same as it does in QuickBasic.
        >
        > Thanks.
      • pendl2megabit
        Colin, he is converting old QBasic code, so he knows the structure of the files ;-) Don, you can build custom PUT and GET functions to create RAFs with on the
        Message 3 of 7 , Aug 2, 2004
        • 0 Attachment
          Colin,
          he is converting old QBasic code, so he knows the structure of the files ;-)

          Don,
          you can build custom PUT and GET functions to create RAFs with on the fly
          field and record length.
          There is a post in the archive of this group showing custom functions for the
          problem accessing a RAF on a CD-ROM (read only).

          What you will need is:

          1) open RAF as binary (open read/write)
          2) use SEEK to go to the records start
          3) use INPUT$(#handle, numberOfChars) to get the record
          4) use PRINT to write a record
          5) use LOC(#handle) to get the current position
          6) use MID$() and TRIM$() to get the fields

          HTH,
          Stefan Pendl


          > -----Urspr√ľngliche Nachricht-----
          > Von: cmcmurchie
          > Gesendet: Montag, 02. August 2004 14:28
          > An: libertybasic@yahoogroups.com
          > Betreff: [libertybasic] Using variables in creating Random Access Files
          >
          >
          > Don, Do you know the structure of Dbase 4 files, or could you post a
          > link to somewhere that explains it?
          >
          > Just guessing, but you should be able to extract record length
          > information from the header, and with suitable manipulation, then use
          > that to read the data part of the file (you may have to split the
          > file). You would at least know when a should be in
          > open "c:\test.txt" for random as #1 len = a
          >
          > Colin
        • POR20@aol.com
          Colin, I read the headers in one byte at a time. I m on the road but will you send you the code for that. Anyway, the physical ascii code # for one byte in
          Message 4 of 7 , Aug 4, 2004
          • 0 Attachment
            Colin,

            I read the headers in one byte at a time. I'm on the road but will you send
            you the code for that. Anyway, the physical ascii code # for one byte in the
            header is actually the field length. There's also a specific byte that ends
            the header. Once you know where the header ends and you know all the field
            lengths, you can read in the header, then begin reading in the dbf file data and
            doing anything you want with it.

            I've gotten around the random access problem in Liberty Basic initially by
            simulating a random access read using a sequential input statement and a parsing
            routine using a MID$ function -- since all my files use the old string
            conventions from QuickBasic.

            Thanks for your thoughts,

            Don


            [Non-text portions of this message have been removed]
          • POR20@aol.com
            Stefan, Thanks. I ll check that out. Initially, I m simulating random access using sequential access. Reading is easy using this method, but writing will be
            Message 5 of 7 , Aug 4, 2004
            • 0 Attachment
              Stefan,

              Thanks. I'll check that out. Initially, I'm simulating random access using
              sequential access. Reading is easy using this method, but writing will be
              more difficult. Your way sounds a bit more elegant.

              Thanks,

              Don


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