BBC BASIC for Windows
« How do you copy the text from PRINT statements ? »

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



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: How do you copy the text from PRINT statements ?  (Read 487 times)
OldBeebMan
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx How do you copy the text from PRINT statements ?
« Thread started on: Apr 1st, 2016, 09:06am »

Hello, there. Whilst I am not exactly a computer guru I have been programming in BBC BASIC since about 1983 !
About 3 or 4 years ago I was forced to use Windows more and more and, although I have VirtualAcorn, it seemed useful if there
were a BASIC available on Windows. Hence my discovery of BB4W.

Now for my problem.
I am writing a program to do with home electricity generation from PV v. electricity consumption.
The whole input and output is in the form of text and numbers. But I have not found a way to copy the output of PRINT statements to a text file. I could do it in RISCOS, but really want to solve this problem.
1. In the BB4W window, with a program listing, I click on Run.
2. Another (untitled) window with filetype icon opens with the output of the PRINT statements.
3. But this (untitled) window seems to be "inert". I cannot select and copy the displayed text, and clicking on the filetype icon shows nothing like "Save".

Please, has anyone a solution ? I am sure that there is one, because it seems to be such an obvious need.

In RISCOS you can simply save the Task Window.
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: How do you copy the text from PRINT statement
« Reply #1 on: Apr 1st, 2016, 11:27am »

Hi,

Windows is a bit different from RiscOs...

It is possible to capture the text in the output window using Ctrl-Tab - you could then paste it into a word processor.

A better approach might be to open your file, print the information to the file as well as to the screen, and then close the file:

Code:
      f%=OPENOUT("Mydata.dat")
      string1$="Hello world!"
      PRINT string1$
      PRINT#f%,string1$
      mydata=3.14159
      string2$="The value of may data was "+STR$(mydata)
      PRINT string2$
      PRINT#f%,string2$
      CLOSE#f%
 


I've assumed here that you want the information as a text file you can open and read in another program, so I've converted the numerical data to a string. It's fine to print numbers to files directly, but they won't make sense as text if you do.

On the other hand, if you want to store the data to read back into another program later, saving it as a number makes sense.

If you use f%=OPENOUT"" (or "*.dat", etc) a File Open dialogue will open, allowing you to choose your file name and where to save it.

Hope that makes sense - come back if it doesn't solve your problem.

Best wishes,

D
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: How do you copy the text from PRINT statement
« Reply #2 on: Jun 1st, 2016, 07:37am »

Personally I prefer BPUT#F% rather than PRINT#F% and then read from the file with a$=GET$#F% The advantage is that your file will be human readable as well as machine readable.

Try running this:
F%=OPENOUT("C:\Test.txt")
PRINT#F%,"Kendall"
PRINT#F%,"Down"
BPUT#F%,""+CHR$13
BPUT#F%,"Kendall"+CHR$13
BPUT#F%,"Down"+CHR$13
CLOSE#F%
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