BBC BASIC for Windows
« Reading Files »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:04pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Reading Files  (Read 719 times)
Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Reading Files
« Thread started on: May 20th, 2013, 5:19pm »

Hi,
After testing, it appears that when reading strings into variables (e.g. INPUT#fn, text$), if the final string in the file does not contain a CR (CHR$13) at the end, it will not read it (or will ignore it). If this is the case (and I'm not just making a mistake), is there any way to overcome this? The file I'm reading from may not be created from a BB4W program, therefore no guarantee can be made that the file will end with a CR.
Matt

Ignore this. Brain's not working. Answer's staring me in the face in Help.
« Last Edit: May 20th, 2013, 7:14pm by Matt » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Reading Files
« Reply #1 on: May 20th, 2013, 10:06pm »

on May 20th, 2013, 5:19pm, Matt wrote:
The file I'm reading from may not be created from a BB4W program, therefore no guarantee can be made that the file will end with a CR.

INPUT# is primarily intended to read data which was written using PRINT#. That is particularly true of numeric data, which is stored by BBC BASIC in a 'private' binary format in order to preserve accuracy.

If you want to read data from a file which was not originally written using PRINT# then GET$# is often a better choice. GET$# accepts a wider range of delimiters (CR, LF or NUL) and if the final data item in the file is not terminated it will still be returned.

So, to store data in a file so that it can later be retrieved by the same, or another, BB4W program, use PRINT# and INPUT#. To read data written by a different program, use GET$# for textual data and BGET# for binary data.

Richard.
User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Reading Files
« Reply #2 on: May 21st, 2013, 05:19am »

Thanks Richard.

I thought I knew INPUT# so didn't really take in what the Help was saying or its alternatives. Serves me right for not paying attention.

Matt
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls