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

3

10

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?

Tutu answered 27/11, 2009 at 23:16 Comment(8)
+1 just for the pure WTF nature of this question.Wintry
Perhaps you could explain the concept of a "fixed-width register file" in more detail?Suite
In a fixed-width file, all registers (rows) have the same length in bytes and the same structure. Just like fwriteing the contents of a struct in C one after another.Tutu
What's scary is that it's not the only question tagged gw-basic on SO...Uranology
Might have been an issue with the path, filename, or working directory he used.Depression
Just out of curiosity... please tell us about how he is making a living at this.Lent
Jeanne: he is a freelancer programmer that has developed software for some specific domains. The technology he uses is old, but it has never been a problem since the programs don't need any sofisticated functionalities, and he understands (and meets) well the requirements of his customers. They don't care (or even notice at all, I think) whether the program has a fancy GUI or it works on the terminal, as long as they do what they need.Tutu
(I noticed that where I said "register" what I really meant was "record". Both words are the same in Spanish)Tutu
M
8

I Downloaded 2.01 here and used the command:

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

from this site.

Margaretemargaretha answered 27/11, 2009 at 23:47 Comment(2)
Great! As soon as he confirms that this works, I'll accept your answer (and force him to download the latest version^W^W^W^W learn a modern language)Tutu
Binary Worrier: that explains why none of my 25-year-old friends could help me :)Tutu
R
3

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.

Ribera answered 27/11, 2009 at 23:47 Comment(1)
+1: I'm up-voting everything to do with this question, if only out of nostalgia :)Hefter
H
0

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

Hefter answered 28/11, 2009 at 0:2 Comment(4)
P.S. Buy your Dad a good primer on VB.Net, he'll be surprised how quickly he'll pick up the basics.Hefter
Or download VB.NET Express, burn it on to the CD? And watch the expression on his face when he sees that GWBasic fits on one floppy (about 120K used out of 1.44Mb) in comparison to ~460Mb CD - Priceless!!! :)Phenylketonuria
I really would like that he learns a modern language, but he has a large working codebase and he wouldn't actually benefit of the cost of migrating what he already has developed. Besides, he hasn't really learnt any new technologies for a while so I think his mental muscle is totally out of training to learn a new language from scratch.Tutu
Actually, he also does some really neat stuff with Excel which serves well for his purposes. Except for the ocasional macro he asks me to write for him :)Tutu

© 2022 - 2024 — McMap. All rights reserved.