Author |
Topic: How do you copy the text from PRINT statements ? (Read 487 times) |
|
OldBeebMan
New Member
member is offline


Posts: 2
|
 |
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.
|
|
Logged
|
|
|
|
DDRM
Administrator
member is offline


Gender: 
Posts: 321
|
 |
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
|
|
Logged
|
|
|
|
KenDown
Full Member
member is offline


Posts: 181
|
 |
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%
|
|
Logged
|
|
|
|
|