BBC BASIC for Windows
« Moving and array between programs »
Welcome Guest. Please Login or Register. Apr 5th, 2018, 10:17pm
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.
Re: Moving and array between programs
« Reply #13 on: Oct 28th, 2014, 11:02am »
Quote:
You say about statement 300: “Overhere GinFileNum% equals 0…”
I've copied your program from your forum message and executed it without first saving it. As a result GinFileNum% equals 0. Nothing to do with your coding and entirely my error (see also Richard's explanation) Quote:
changing line 50 from fnum=OPENIN(“GinFile”) to fnum=OPENIN(“GinFile.dat”) made no difference to my result
Yes it does.You've made this correction (before adding Richard's corrections) and it didn't work because in the first program you did create the file GinFile.dat but left it empty. When you then tried to read from it with your second program it executed correctly but without finding any data in the file. Therefore the values shown were all equal to zero.
Now that you've applied the corrections that Richard correctly suggested the first program does write to the file and the data that you read with the second program are no longer zero.
As a final check (only for your better understanding) replace line 50 fnum = OPENIN("GinFile.dat") again to 50 fnum = OPENIN("GinFile") but keep Richard's corrections in the first program. Then run both program's to see that the second one won't open the file anymore.
I hope this leads to a better understanding, certainly not adding to any confusion.
Eddy
Logged
rtr2 Guest
Re: Moving and array between programs
« Reply #14 on: Oct 28th, 2014, 12:22pm »
As a final check (only for your better understanding) replace line 50 fnum = OPENIN("GinFile.dat") again to 50 fnum = OPENIN("GinFile") ... see that the second [program] won't open the file anymore.
I'm not keen on the idea of introducing a deliberate fault just to observe that it causes the program to fail. In any case the effect may not be what you describe - suppose one of the programs has been saved with the name 'GinFile' (i.e. as the file GinFile.bbc) or that a data file 'GinFile' has previously been created by an earlier version of the first program. Either way the modified code will open the file but it will report the wrong results!
Quote:
I hope this leads to a better understanding, certainly not adding to any confusion.
I fear it is more likely to confuse than to educate!