Qbasicnews.com

Full Version: More help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Newbies always need help!


If i want to input a lot of data into a file, should i use many arrays or a double dimension array?

Also, if i have to input an array into a file, how do i?

Then, i need to read from the array and print whatever is required.

P.S. - I need the easiest and shortest way to do the above mentioned.

Thanx.
Wrong forum. Post in the newbie forum next time.

>If i want to input a lot of data into a file, should i use many arrays or a double dimension array?

Depends. Are all the arrays of the same length and type? Tell me. Use double-dimension arrays if they are.

>Also, if i have to input an array into a file, how do i?

OPEN "bla.txt" FOR RANDOM AS #1
FOR i% = 1 to 50
PUT #1, , array1%(I%)
NEXT i%
CLOSE

This will write the (integer) array in quickly and efficiently but it won't be easily readable from a text file.

To get the array from the file:

OPEN "bla.txt" FOR RANDOM AS #1
FOR i% = 1 to 50
GET #1, , array1%(I%)
NEXT i%
CLOSE

>Then, i need to read from the array and print whatever is required.

FOR i% = 1 to 50
PRINT array1%(I%)
NEXT i%