QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: badger on September 29, 2020, 02:56:55 pm

Title: files
Post by: badger on September 29, 2020, 02:56:55 pm
Hello

What is the limit of records a random file can have

Badger
Title: Re: files
Post by: Cobalt on September 29, 2020, 03:40:06 pm
I believe its limited by file size now, which is limited by how big your hard disk is.
unless there is a nuance with RANDOM access files I'm missing, as I stick with BINARY almost all the time.
Title: Re: files
Post by: badger on September 29, 2020, 03:46:12 pm
Hello

Wow that is a far cry for the 35000 or so limit from qb4.5 thanks a lot

Badger
Title: Re: files
Post by: bplus on September 29, 2020, 04:00:35 pm
Hello

Wow that is a far cry for the 35000 or so limit from qb4.5 thanks a lot

Badger

35000 is close to limit of INTEGER 32,000+ which might have been a false limit due to number used for record number access.
Title: Re: files
Post by: badger on September 29, 2020, 04:08:34 pm
Hello

that is correct i have used qb anything since the 90s around 32000 was correct. I am now using a long for record length i dont need that much but it is there. I will be using a long to count the records as well

Thanks

Badger
Title: Re: files
Post by: SMcNeill on September 29, 2020, 04:39:26 pm
A quick demo showcases that there's not much of a limit to the number:

Code: QB64: [Select]
  1. DIM junk AS STRING * 1
  2. junk = "X"
  3.  
  4. OPEN "temp.txt" FOR RANDOM AS #1 LEN = 1
  5. PUT #1, 2000000000, junk
  6. PUT #1, 5000000000, junk
  7.  

Warning, the above creates a 5GB file and will take a few moments to run the first time you compile and execute it, as it's allocating disk space and all for that massive text file, before writing those two data entries.

A LONG variable only allows us to access 2,147,483,647 elements before we overflow, and as you can plainly see, we're putting data to records beyond that.  QB64's internals, for records, is probably limited by _INTEGER64 values -- meaning we can have a maximum of 9,223,372,036,854,775,807 records.  If your drive can hold more than that, then you don't need to be coding in QB64!  Instead, you need to send me a few million dollars, and I'll become your personal coding machine, forever more!  :D
Title: Re: files
Post by: Pete on September 29, 2020, 04:43:43 pm
Why not just...

Code: QB64: [Select]
  1. OPEN "temp.txt" FOR RANDOM AS #1 LEN = 1
  2. PUT #1, 5000000000, junk
Title: Re: files
Post by: SMcNeill on September 29, 2020, 04:47:41 pm
Why not just...

Code: QB64: [Select]
  1. OPEN "temp.txt" FOR RANDOM AS #1 LEN = 1
  2. PUT #1, 5000000000, junk

Simply because I was testing various limits (INTEGER, LONG, INT64, signed & unsigned), as I went, waiting to see if any tossed an error.  The 2GB position, I apparently just fell asleep on and didn’t erase afterwards.  :P
Title: Re: files
Post by: badger on September 29, 2020, 04:50:09 pm
Hello

i may be asking a really stupid question here but the put #1, 2000000000, junk puts in 2000000000 records

Badger
Title: Re: files
Post by: SMcNeill on September 29, 2020, 05:06:45 pm
Hello

i may be asking a really stupid question here but the put #1, 2000000000, junk puts in 2000000000 records

Badger

It only puts 1 record to file (the 2 billionth record), and with each record only being 1 byte each, that makes the datafile 2GB in size.  The first 1,999,999,999 records are all nothing more than blank spaces, at this point.