5

So I've been using QBASIC64 today... for old school's sake.

I was wondering:

a) What is the most complex QBASIC code you have ever written was
and
b) What is the most useful code you have written

(examples would be nice but not imperative ^_^ - and this is Community Wiki and just for fun)

Barrie Reader
  • 10,647
  • 11
  • 71
  • 139

7 Answers7

7

GOTO used to be so easy those days :-)

Geek
  • 23,089
  • 20
  • 71
  • 85
  • 1
    Someone once told me they *had to write a whole program without a single GOTO* -- blew my mind out of the water at the time. BASICA anyone? :-) –  Nov 04 '10 at 21:30
2

Although I never used QBasic (I managed to skip the generation of machines that had it) I did write a Z80 assembler in its predecessor, GWBasic, together with support code for some hardware to transfer the resulting machine code to my test platform. It most certainly qualified as complex, as well as being very messy and slow, but that's because I didn't know better (having not taken any data structures and algorithms classes at that point).

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • 1
    Again, similar memories making complex programs that were nothing more than IF statements and GOTOs – Barrie Reader Sep 16 '10 at 13:45
  • There was also GOSUB, but you had to use line numbers for everything (I believe they dropped that in QBasic and good riddance!) and no computed jumps either IIRC. Difficult, nasty and a good place to practice; even Fortran was nice by comparison, and TurboPascal was *wonderful*. Ah, the memories... – Donal Fellows Sep 16 '10 at 20:40
2

Most complex: Huffman coder using a string to store the tree. I don't think i got it working.

Most useful: Palace chat maze editor/generator.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
  • I wrote a complete set of huffman coding routines using Crescent Software's PDQ libary as a proof-of-concept at their request. Unfortunately, it could not compete with the speed of C or assembler routines, which was the requester's original hope, so it was never implemented. It was highly educational for me, though. Learned about huffman encoding through an article in Dr. Dobb's Journal and had to convert the sample code from C to BASIC. – Bill Hileman Nov 17 '17 at 16:15
  • @BillHileman Nice. MIT's old SICP book also has a surprisingly practical example of Huffman's algorithm (and the Monte Carlo one as well), one of few highlights in that long book. – Cees Timmerman Nov 21 '17 at 09:14
1

I never really got so far with QBasic. This would be because I'm not an old programmer. Most I ever did, (fitting both A) and B) ) was make a program the read a number from keyboard, and then calculated 10% of it, pringitng that to screen.

This must have been in 2000, as 10% gst was being introduced in australia. That makes me 9 years old. I remember spending like 6 months looking for a computer with QBasic on it.

Fond memories, of the, not so, distant past

Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
1

Most Useful, and probably most complex: I wrote a quizzer program in QBasic that had mouse support, graphical buttons you could click, etc. It also used a generic file format so you could write new questions and load them in if you wanted to. The code is online if you are interested, although sadly the associated image / data / etc files are lost to time: http://code.google.com/p/justinethier/source/browse/trunk/qbasic_quizzer/project.bas

Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
  • Awesomely long code there! Shame it won't compile on QB64 :'( – Barrie Reader Sep 20 '10 at 10:01
  • You could probably break it down into pieces and get it to work that way, if you really wanted. The lower-level mouse code was written for DOS (not by me) so it might well have to be rewritten. – Justin Ethier Sep 20 '10 at 14:45
1

answer for both a and b: a program where the user would enter the string name and fret number on a guitar and the program would output which note the fret is. BTW, I love qbasic because its simplicity makes it fun!

RCProgramming
  • 452
  • 3
  • 14
1

QBasic was my first experience with programming. I was nine-years old (fourth grade) and we had a 386DX with MS-DOS and Windows 3.1.

I remember having fun hacking the code for Nibbler and Gorillas changing colors and constants and such.

So the most useful and complex program I made was a menu driven application which quizzed the user on math problems: there were ascending numeric levels of difficulty the user could choose from and I remember literally hardcoding 100 arithmetic problems checking the users response and telling them whether they got it wrong or not.

Not sure if I still have that code laying around, I think I might, I'll check tonight and post if I find it!

...alright! I found some stuff. This snippet is part of a file named "TEST1.BAS" and looks like an early version of the program described above. I believe I had a more complete version but it was lost when our hard drive crashed and we weren't able to recover all files.

CLS
PRINT
PRINT "     menu"
PRINT "--------------"
PRINT "1. level 1"
PRINT "2. level 2"
PRINT "3. level 3"
PRINT "4. level 4"
PRINT "5. level 5"
PRINT "6. level 6"
PRINT "7. level 7"
PRINT "8. level 8"
PRINT "9. level 9"
PRINT "10. level 10"
PRINT "11. OTHER"
PRINT
INPUT "Your selection: ", choice%
PRINT

IF choice% = 1 THEN
CLS
DO
   INPUT "what is 4 + 4 ? ", num
LOOP UNTIL num = 8
PRINT
PRINT "correct"

DO
   INPUT "what is 8 - 6 ? ", num
LOOP UNTIL num = 2
PRINT
PRINT "correct"

DO
   INPUT "what is 8 + 7 ? ", num
LOOP UNTIL num = 15
PRINT
PRINT "correct"

DO
   INPUT "what is 9 - 4 ? ", num
LOOP UNTIL num = 5
PRINT
PRINT "correct"

DO
   INPUT "what is 6 + 5 ? ", num
LOOP UNTIL num = 11
PRINT
PRINT "correct"
END IF

IF choice% = 2 THEN
CLS
DO
   INPUT "what is 11 + 6 ? ", num
LOOP UNTIL num = 17
PRINT
PRINT "correct"

DO
   INPUT "what is 21 - 5 ? ", num
LOOP UNTIL num = 16
PRINT
PRINT "correct"

DO
   INPUT "what is 2 * 2 ? ", num
LOOP UNTIL num = 4
PRINT
PRINT "correct"

DO
   INPUT "what is 14 + 8 ? ", num
LOOP UNTIL num = 22
PRINT
PRINT "correct"

DO
   INPUT "what is 17 - 5 ? ", num
LOOP UNTIL num = 12
PRINT
PRINT "correct"

END IF

IF choice% = 3 THEN

END IF

IF choice% = 4 THEN

END IF

IF choice% = 5 THEN

END IF

IF choice% = 6 THEN

END IF

IF choice% = 7 THEN

END IF

IF choice% = 8 THEN

END IF

IF choice% = 9 THEN

END IF

IF choice% = 10 THEN

END IF
Stephen Swensen
  • 22,107
  • 9
  • 81
  • 136