Author Topic: Reading data from data files  (Read 2024 times)

0 Members and 1 Guest are viewing this topic.

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Reading data from data files
« on: May 27, 2020, 12:23:43 pm »
Gosh!  It's over 30 years since I last wrote some BASIC to pull in a stream of numbers from a file.

The resulting program must (for reasons that are too complicated to explain) be QB45 compatible, although it will also be run under QB64.

So... are there any tricks to getting QB to navigate to a file's location?  Are there any libraries out there that do this?

Trivially simple for modern-era code, I suppose, but we're talking old school here.

TIA

Malcolm

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Reading data from data files
« Reply #1 on: May 27, 2020, 12:32:35 pm »
This may be a place to begin. In this section of my tutorial I outline file input/output and drive navigation.

http://qb64sourcecode.com/task13.html
In order to understand recursion, one must first understand recursion.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Reading data from data files
« Reply #2 on: May 27, 2020, 04:20:31 pm »
I'm not sure if there is also an example in the tutorial with the INPUT$ function, this is the right function, that definitely works properly for reading binary files in both QB 4.5 and QB64.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Reading data from data files
« Reply #3 on: May 27, 2020, 04:59:19 pm »
I'm not sure if there is also an example in the tutorial with the INPUT$ function, this is the right function, that definitely works properly for reading binary files in both QB 4.5 and QB64.

You're correct. In the old version of the tutorial I included INPUT$ with a demo of how to use it as a hidden password entry field. I'll make a note to add INPUT$ to task 13 with examples. Thanks for pointing that out.
In order to understand recursion, one must first understand recursion.

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: Reading data from data files
« Reply #4 on: May 27, 2020, 05:18:24 pm »
I'm not sure if there is also an example in the tutorial with the INPUT$ function, this is the right function, that definitely works properly for reading binary files in both QB 4.5 and QB64.

That's useful, as I had explicitly ruled out INPUT$ in favor of LINE INPUT. Looks like I need to do more reading!

Malcolm

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: Reading data from data files
« Reply #5 on: May 29, 2020, 05:44:41 am »
This may be a place to begin. In this section of my tutorial I outline file input/output and drive navigation.

http://qb64sourcecode.com/task13.html

Thanks, Terry.  That was very useful.  I didn't know about some of those new QB64 commands.

Malcolm