Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Array problem

Author
Message
Eckie Thump
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location:
Posted: 23rd Oct 2003 20:04
It seems I've forgoten more about basic than I ever remembered
Since I never kept any of my QBasic source I'm now struggling.

I'm pretty sure I had an array in one of my past programs that was used for storing a database of questions and answers for a quiz.

It was something like this:-

question$(1)=Question$,Answer1$,Answer2$,Answer3$,Answer4$,RightAnswer$,Value
question$(2)=Question$,Answer1$,Answer2$,Answer3$,Answer4$,RightAnswer$,Value
question$(3)=Question$,Answer1$,Answer2$,Answer3$,Answer4$,RightAnswer$,Value
question$(4)=Question$,Answer1$,Answer2$,Answer3$,Answer4$,RightAnswer$,Value

The questions and answers were stored in a file and read to the array at the start of the quiz.
It was just a matter of picking a random question to ask from the array.

So, my question:
What is the correct syntax for declaring/dimensioning this array and will load/save array work with this type of array?

Thanks in advance,
Eckie.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 23rd Oct 2003 20:19 Edited at: 23rd Oct 2003 20:20
arrays are option base Zero so if you need four then do:

DIM Question$(3)

but you may want to use a User Definded TYPE for what you asked above aand then make an array of the Type Object.

-RUST-
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 23rd Oct 2003 20:23
dim question$(4,7)

Arrays start at 0, but there is no reason why you can't leave it blank if you find it easier to start at 1.

In the dbpro help it's under home > principles > data types and variables.

When using save/load array use save array(0)/ load array(0)

If you have dbpro then it doesn't currently check if you are read/write to the array out of its range.
dim array(1)
array(2)=55
doesn't cause an error.

You also might want to look into user defined types, again under home > principles > data types and variables in the help.
Eckie Thump
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location:
Posted: 24th Oct 2003 22:37
Thanks,
will look in the help and post back if I'm still confused

Login to post a reply

Server time is: 2024-11-25 14:49:50
Your offset time is: 2024-11-25 14:49:50