tags:

views:

275

answers:

3

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?

+5  A: 

I Downloaded 2.01 here and used the command:

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

from this site.

marg
I am very, very impressed.
Pascal Cuoq
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)
Roberto Bonvallet
+1, have very vague, 25 year old memories of that syntax!
Binary Worrier
Binary Worrier: that explains why none of my 25-year-old friends could help me :)
Roberto Bonvallet
Funfact: I'm 23 ^^
marg
Oh the memories!
JYelton
+1  A: 

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.

Pascal Cuoq
+1: I'm up-voting everything to do with this question, if only out of nostalgia :)
Binary Worrier
A: 

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

Binary Worrier
P.S. Buy your Dad a good primer on VB.Net, he'll be surprised how quickly he'll pick up the basics.
Binary Worrier
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!!! :)
tommieb75
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.
Roberto Bonvallet
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 :)
Roberto Bonvallet