BBC BASIC for Windows
« Writing multiple variables to a file »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:15pm



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: Writing multiple variables to a file  (Read 651 times)
johnblack
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Writing multiple variables to a file
« Thread started on: Oct 14th, 2013, 12:56pm »

I am trying to use this code to write multiple user inputs to a file:

A=OPENOUT "PlayerAttribute"
PRINT#A,PoneName$,PoneSkill%,PoneStrength%
CLOSE#A

If only takes in the PoneName$ variable and tends to make random workds out of my other variables (which are derived from random numbers.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Writing multiple variables to a file
« Reply #1 on: Oct 14th, 2013, 1:47pm »

on Oct 14th, 2013, 12:56pm, johnblack wrote:
IIf only takes in the PoneName$ variable and tends to make random workds out of my other variables (which are derived from random numbers.

It's doing what it should, but you won't be able to read the (binary) numeric values in a text editor. If you read the values back in from the file it will work fine:

Code:
 A=OPENIN "PlayerAttribute"
 INPUT#A,PoneName$,PoneSkill%,PoneStrength%
 CLOSE#A 

If you specifically want to be able to read the numbers in something like WordPad or Word then you'll have to write them as strings:

Code:
 A=OPENOUT "PlayerAttribute"
 PRINT#A,PoneName$,STR$(PoneSkill%),STR$(PoneStrength%)
 CLOSE#A 

Incidentally I don't recommend omitting the file extension, because a '.BBC' extension will be added automatically and the resulting file could easily be mistaken for a program. Better to choose a more appropriate extension, e.g:

Code:
 A=OPENOUT "PlayerAttribute.dat" 

Richard.
User IP Logged

johnblack
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Writing multiple variables to a file
« Reply #2 on: Oct 14th, 2013, 2:20pm »

Awesome! Thank you for all your help. You have taught me all I already know about BBC basic through your manual, which is really very thorough.

I am developing a scheme of work for some year 8 students, if you want it when I am finished you are welcome to a copy.

Thanks for your help!
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