How to create a plain text file in GW-BASIC 2.01?

3.4k views Asked by At

My dad learnt programming in the 80s and he is still stuck with GW-BASIC (and making a living out of it). He was asked to create a CSV file, but he only knows how to create files of fixed-width records.

I found on the web that the syntax for opening plain-text files is:

OPEN file$ FOR OUTPUT as #1

but he claims it doesn't work. The interpreter he uses is the version 2.01. According to Wikipedia, the most "modern" version is 3.23 (1988).

Does anyone know how to create a plain-text file in such an outdated version of GW-BASIC?

3

There are 3 answers

2
marg On BEST ANSWER

I Downloaded 2.01 here and used the command:

open "o",#1,"test.txt" 

from this site.

1
Pascal Cuoq On

I can confirm that:

OPEN "FOO.TXT" FOR OUTPUT AS #1

was the syntax used to create text file FOO.TXT in GW-BASIC.

If that command did not exist in version 2.01 probably there wasn't any way to do this in that version. EDIT: I was wrong, see marg's answer. It existed but with a more difficult syntax to remember.

If your father saved the program in which he has to create this file this as ASCII:

SAVE "PROG.BAS",A

Then it is likely that he would be able to load it in any of GW-BASIC 3.32, QBASIC, QuickBASIC, and perhaps even Visual Basic, and then be able to use this command.

4
Binary Worrier On

Dude, GW-Basic, man that brings back some memories. I learned to program with something VERY similar to GW-Basic many (many) moons ago.

I downloaded the "modern" version from a link on that wikipedia page, and got this to work.

10 open file "c:\mark.txt" for output as #1
20 print #1, "Hello world"
30 close #1

This will create a text file on the root of C drive called "mark.txt" (my name is mark).

Hope this helps