Hi.
I am posting here because I thought maybe you guys could help me with a QBasic thing.
I am trying to make educational software in Qbasic, namely a quiz creator software. I will have the Questions and quiz answers in files on the hard disk.
How do I print the questions, answer selections, etc. on specific lines of the file and then read from specific lines on the file? Quizzes may have up to 50 questions each and I'm trying to have a simple way to achieve this.
Thanks!

You probably don't want to hear this, but I feel obligated to say you should move up to a more robust language. QBasic (unless it's the rarer QBasic Pro version), can't even create an executable file.

Lots of ways to do this. Maybe something as simple as this:

Your data file will have even numbered rows of text, for the questions, and use the odd numbered rows of text, for the answer.

You could display both of them easily, by reading in an even numbered row first (never an odd numbered row), and then having row+1, be the answer to that question.

You could certainly get more organized with this: using records and fields, but that sounds like it's more than you need.

After searching around, I found that you can now download for free such things as QuickBasic, which does make executables and has a few extras compared to the tamer, lamer QBasic that is only interpreted. You can also get TurboPascal, which might be a better choice for this type of app. Pascal was foreign to me at first, but it soon became my language of choice, and the first "meaningful" software I created was with Pascal. There are others, like C++, but I wouldn't use if for anything like this, assuming I could ever make any sense of it in the first place. You can even get VB for DOS free, giving you the ability to make DOS forms and using at least SOME graphics capabilities!

Hi,

Read up on Random Access files. That way you can access questions by using a record number.

Going from memory, you declare a structure and can then say something like:

Open "FileName" as #1 For Read/Write access Random
For r=1 to 20
    Get #1,s$
    ..... process s$
Next r
Close #1

Rich

This article has been dead for over six months. Start a new discussion instead.