Posts: 48
Threads: 11
Joined: Jun 2022
Reputation:
0
Wait, I'll try to explain!
The code I had proposed was kept to a minimum, just to make the problem clear without giving too much weight to the code itself.
The TEST.BAS file is a simple text file (perhaps better called TST.TXT) and contains only one line.
Including the quotation marks, the line is as follows:
"QB64 Phoenix "+CHR$(138)+" (is) beatiful"
The code that opens and reads the file loads the entire line and puts it in the j$ variable.
The problem - but maybe it's me who doesn't see something obvious - is that the compiler (or I don't know what else) doesn't recognize the instructions.
In fact, if you were to write and compile this line of code:
j$= "QB64 Phoenix "+CHR$(138)+" (is) beatiful"
I get:
QB64 Phoenix è (is) beatiful
Instead, reading the line from the file and assigning it to j$ - running the compiled code - I just only get:
"QB64 Phoenix "+CHR$(138)+" (is) beatiful"
Posts: 1,587
Threads: 59
Joined: Jul 2022
Reputation:
52
... could use RUN on the BASIC source code? That's in addition to the code that loads that same source code as a text file.
The problem is that if there is no EXE file on Windows for TEST.BAS it will be created by the QB64 compiler and it will take many seconds. If the EXE already exists then it's just run. However, it might not have come from the source code you thought was in TEST.BAS! This is easy to investigate: without compiling TEST.BAS, just find any other EXE file, copy it to QB64 directory and rename it TEST.EXE. The RUN statement will happily run that without checking to see if the BASIC source code was compiled to get that EXE file.
You could add a sanity check: first load the BASIC source code as text file. Then make sure is the right one by searching a string loaded from the file, such as + CHR$(138) + . If there is a match then you ask to RUN that source code.
But maybe I shouldn't be proposing to use RUN...
Otherwise you will need a BASIC interpreter as part of your QB64 program. Load the BASIC source code as text file, then have the interpreter work with it for the result you originally expected.
Posts: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
Can you not just write the text file with the formatting already done?
OPEN "Test.txt" FOR OUTPUT AS #1
PRINT #1, " QB64 Phoenix è (is) beatiful"
CLOSE #1