Author Topic: files  (Read 4261 times)

0 Members and 1 Guest are viewing this topic.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
files
« on: September 29, 2020, 02:56:55 pm »
Hello

What is the limit of records a random file can have

Badger

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: files
« Reply #1 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.
Granted after becoming radioactive I only have a half-life!

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: files
« Reply #2 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: files
« Reply #3 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.

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: files
« Reply #4 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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: files
« Reply #5 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
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: files
« Reply #6 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: files
« Reply #7 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
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline badger

  • Forum Regular
  • Posts: 148
    • View Profile
Re: files
« Reply #8 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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: files
« Reply #9 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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!