BBC BASIC for Windows
« The Most Basic READ and WRITE DATA LESSON EVER!! »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:54pm



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: The Most Basic READ and WRITE DATA LESSON EVER!!  (Read 682 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy The Most Basic READ and WRITE DATA LESSON EVER!!
« Thread started on: Mar 14th, 2016, 04:03am »

I have simplified this as much as I can..
Now even the most Novice beginner should be able to store and retrieve data easily..
Although this wasn't my intended plan, I guess I don't want to reinvent the entire wheel !
When I first started learning programming this is the style of lessons I saw..

And in 1982 I thought space bar had something to do with gaming, even though I didn't have any games at the time.
Programming was my game (self taught)

The program is easier to understand once it is in the BBC editor
Code:
      REM THE SIMPLEST FILE DATA MANAGEMENT EXAMPLE ON THIS FORUM !!
      REM OPEN A FILE FOR OUTPUT AND WRITE 4 DIFFRENT PIECES OF DATA (Even if it doesnt look like it)
      A=OPENOUT(@usr$+"JUNK.DAT")
      REM The next command line will write 3 strings and 1 number to the file*******
      REM VVVVV notice how A becomes #A as an identifier or device handle FOR THE FILE YOU MAKE***
      PRINT#A,"REALLY?","THERE ARE",4,"DATA SECTIONS TO THIS DATA"
      CLOSE#A
      REM OPEN A FILE AND READ THE CONTENTS AND PRINT THEM ON THE SCREEN
      A=OPENIN(@usr$+"JUNK.DAT")
      REM VVVVV notice how A becomes #A as an identifier or device handle FOR THE FILE YOU READ***
      INPUT#A,A$,B$,N,C$
      PRINT A$;" ";B$;" ";N;" ";C$
      REM ^^^^^^ The read must be the same as the written file for accuracy ^^^^^
      REM break down the elements of the data so they can see
      PRINT
      PRINT "1 ";A$
      PRINT "2 ";B$
      PRINT "3 (this is not a string) -";N
      PRINT "4 ";C$
 CLOSE#A    
 END
 
« Last Edit: May 27th, 2017, 03:37am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
cheesy Re: The Most Basic READ and WRITE DATA LESSON EVER
« Reply #1 on: Mar 14th, 2016, 04:44am »

Code:
REM VVVVV notice how A becomes #A 


The # is really part of the file keywords like INPUT# and BB4W lets you put a space between the INPUT and the # but the # is not in any way a prefix of the variable name as you implied. The # is telling the program that the input is not coming from the keyboard but from some other channel, in this case the filing system.
User IP Logged

michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy Re: The Most Basic READ and WRITE DATA LESSON EVER
« Reply #2 on: Mar 14th, 2016, 04:53am »

I can only relate it to a device, as I am comparing its usage to my previous platform..
Normally #1 or #a ect would have meant a device handle

A window or text box or graphics screen would require a device handle such as #f or #1 or #2 or whatever you wanted.

Thanks for letting me know that the file handle ---- A was not changed..


« Last Edit: Mar 14th, 2016, 05:01am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Zaphod
Guest
cheesy Re: The Most Basic READ and WRITE DATA LESSON EVER
« Reply #3 on: Mar 14th, 2016, 05:38am »

You can show that the # is not part of the variable in BB4W if you put in things like INPUT # (A) or INPUT# (2*A/2)
What comes after the # only has to be something that evaluates to a channel number. This may well be different to other dialects of BASIC.
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