11-07-2004, 05:47 AM
quickbasic 4.5 question please.
Is it possible to load data from a file where some of the data is in one part , (14, 18, and 23) and the rest of the data is in another part (44,66,77, and 99)
I know the program below won't work because I cant figure out how to read data from (score . qbasic wants to start at the beginning of file. But that won't work.
CLS
DIM age(3) AS INTEGER
DIM score(14) AS INTEGER
OPEN "data.txt" FOR INPUT AS #1
DO UNTIL i = 3
i = i + 1
INPUT #1, age(i)
LOOP
CLOSE #1
PRINT age(i);
OPEN "data.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
i = i + 1
INPUT #1, score(i)
LOOP
CLOSE #1
PRINT score(i);
end
The data file is as follows:
age:
14
18
23
misc. comments and information here
gljglrkgjnrlikg
rkrgjakgljgkl
rgakgjkrgjrg
score:
44
66
77
99
Is it possible to load data from a file where some of the data is in one part , (14, 18, and 23) and the rest of the data is in another part (44,66,77, and 99)
I know the program below won't work because I cant figure out how to read data from (score . qbasic wants to start at the beginning of file. But that won't work.
CLS
DIM age(3) AS INTEGER
DIM score(14) AS INTEGER
OPEN "data.txt" FOR INPUT AS #1
DO UNTIL i = 3
i = i + 1
INPUT #1, age(i)
LOOP
CLOSE #1
PRINT age(i);
OPEN "data.txt" FOR INPUT AS #1
DO WHILE NOT EOF(1)
i = i + 1
INPUT #1, score(i)
LOOP
CLOSE #1
PRINT score(i);
end
The data file is as follows:
age:
14
18
23
misc. comments and information here
gljglrkgjnrlikg
rkrgjakgljgkl
rgakgjkrgjrg
score:
44
66
77
99