Computing.Net > Forums > Programming > QBasic Question...Arrays

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

QBasic Question...Arrays

Reply to Message Icon

Name: Max
Date: July 23, 2003 at 15:58:06 Pacific
OS: 95
CPU/Ram: ???
Comment:

Total newbie to programming & QBasic...stuck on a VERY simple program. Basically, I need to transfer data from a Notepad file into the program (as an array). I need to transfer about 200 numbers, but every time I try to input more than 10, I get an error message...Please help!



Sponsored Link
Ads by Google

Response Number 1
Name: egkenny
Date: July 23, 2003 at 19:04:05 Pacific
Reply:

It would help if you posted your program.
Here is a program that reads 200 DOUBLES from a text file. It then prints out the numbers to the screen.
CONST MAX = 200
DIM n(MAX) AS DOUBLE
DIM i AS INTEGER
OPEN "f:\my.dat" FOR INPUT ACCESS READ AS #1
FOR i = 1 TO MAX
INPUT #1, n(i)
NEXT i
CLOSE #1
FOR i = 1 TO MAX
PRINT i, n(i)
NEXT i



0

Response Number 2
Name: Max
Date: July 24, 2003 at 08:34:07 Pacific
Reply:

Thanks, egkenny...I'll try that. But just in case, here's what I tried to do first...

OPEN "datafile.txt" FOR INPUT AS #1
FOR n=1 to 200
INPUT #1, a(n)
PRINT a(n)
NEXT n
CLOSE #1
END


0

Response Number 3
Name: egkenny
Date: July 24, 2003 at 11:25:59 Pacific
Reply:

BTW, there should not be a problem with the size of your array. I tested QBASIC to see what the limits are. The limits depend upon the the data type the number of dimensions. In any case the limits for a one dimensional array of any number type is much larger than 200. You did not say what version of QBASIC you were using. I did my tests with the QBASIC from DOS 6.22 that came with Windows 95. I ran this QBASIC under Windows XP.


0

Response Number 4
Name: Max
Date: July 24, 2003 at 12:13:23 Pacific
Reply:

Oops...sorry, forgot to include that info. I'm using QBasic 4.5 on Windows 95. But I've been having other problems with the program, supposedly because of not having enough conventional memory (which just doesn't make sense!). Anyways, I tried your code, and it worked beautifully. Thanks a lot for all your help!!!


0

Response Number 5
Name: egkenny
Date: July 25, 2003 at 16:32:18 Pacific
Reply:

It sounds like you have QuickBASIC 4.5 which is based on QBasic. I tested the code in Qbasic 1.1 which came with DOS in Windows 95. QuickBASIC was a seperate program sold by Microsoft. I also have QuickBASIC 4.5. QuickBASIC has many improvements over QBasic. The major one is that you can compile your program and produce an executable ".exe" file.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Html Alignment C# and Excel



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: QBasic Question...Arrays

QBasic Question www.computing.net/answers/programming/qbasic-question/7005.html

qbasic question www.computing.net/answers/programming/qbasic-question/9548.html

Assembly Question - array compare www.computing.net/answers/programming/assembly-question-array-compare/10469.html