arrays, sequential files

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
arrays, sequential files

Post by Guest » Tue Nov 11, 2003 7:03 pm

OK, call me a dummy. :o I am writing a program that involves creating, & opening  a sequential file, then writing it to an array. 1st I am kinda confused on the whole array concept. "anybody know "ARRAYS FOR DUMMIES"? 2nd, it says file already open but I wrote "close fole #1" in my code. help. I am failing AND I am on academic probation. I cant lose my financial aid. ANYBODY IN AZ THAT CAN TUTOR ME ?  :'(

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: arrays, sequential files

Post by frankiebaby » Wed Nov 12, 2003 12:29 am

well to close a file in qbasic, u must use close #1, not close file #1. now, about arrays:

One dimensional arrays are kind of like a divided drawer.
You only want one kind of information in a particular drawer, and inside that drawer you want the information organized or ordered in some way as so you can easily find the information later. SO, if our drawer was named SOCKS we would have several boxes in a column in our drawer and each would have one pair of socks in them, Each with a label, maybe by size. This keeps all data (or socks) in one place.

SOCKS
---------------------
|   1   |  2   |  3
---------------------

Multidimensional arrays are like whole filing cabinets, with more than one drawer:

---------------------------------
|socks | shoes  | pants   |
|--------|----------|----------|
|this    | that     | other thing|
-------------------------------------

so, if you had a bunch of students test grades:
Say there are 40 students:

DIM GRADES (1 to 40) as INTEGER
Now, you can store/find each students grade using only one variable to reference them

to get student 1's grade:
PRINT GRADES(1)

to get student 5's grade:
PRINT GRADES(5)

to get student x's grade:
PRINT GRADES(x)

to change them:
GRADES(5) = 90  'this makes student 5's grade a 90

I hope this helps some, let me know if you need any more help, or email me

Post Reply