Qbasic question about files...
Mon Jan 15, 2007 1:34pm

Alright, this might seem to be out of right field but...

How can I load the contents of a file easily into a matrix without having to enter each element individually?




FOR x% = 1 TO 5
FOR y% = 1 TO 5
matrix(x%, y%) = #1


INPUT #1, matrix(1, 1), matrix(2, 1), matrix(3, 1),....

The second way is the only way I've gotten to work so far but that's taking up WAYYYY too much space and time. I tried using DATA and READ but that makes the data hard coded into the program. (Something I DO NOT want...)

...Any ideas?

    • You'll probably say "duh" when you read this... - Puckdropper, Mon Jan 15 2007 8:04pm
      Change this line: matrix(x%, y%) = #1 To: INPUT #1, matrix(x%, y%) It reliably printed out the contents of my info.dat (I used unique data, not all 2's.)
      • OMG... DUH! - Nuke, Tue Jan 16 2007 5:56am
        LMAO. hahaha Thanks so much! ...about the 2's, that was just so I could quickly throw together a mock file.
        • Still having problems... - Nuke, Tue Jan 16 2007 6:51am
          It's only displaying the last line when using the locate command, but without it spits it all out. The locate command works when I use a static character though. (Which is why I have no idea what's wrong...) Here's what I have: CLS DIM matrix(1 TO 5, 1 TO 5) AS INTEGER PRINT "Opening MATRIX.D... more
          • Puckdropper was on the right track with the white spaces. I stumbled back on this topic because I was checking the old news entries and this was linked. Because it was never solved, I tried to recreate it. Sure enough, it did just as it did back then (why wouldn't it?) Doing the fol... more
            • You read the manual for the PRINT statement? - Puckdropper, Wed Sep 01 2021 6:41pm
              Who does that? Seriously, WHO DOES THAT? I get why they did that, it's kinda annoying to do a cout when you want to make a simple table. print "My Values", value, value2, value3 is much cleaner. (I think I read the manual for print back in like 1999. Oh those wild "end of the mil... more
              • jumping to documentation when I have a question about how/why something is working not like I expect it to. COBOL is full of weirdnesses and multiple ways to do things. Example, here's one of the DISPLAY statement's possible syntaxes: Source: more
                • I think I pretty much learned QB from the docs - Puckdropper, Sun Sep 26 2021 3:54am
                  We didn't really have Internet, I didn't really have good books (or a library), so it was all the stuff included on the system. It's too bad good help like QB had never really took off.
                  • I sort of did as well... - Erik_, Tue Sep 28 2021 11:24am
                    at least in the beginning. That said, I feel like I rarely got into more than a small set of the commands available and just found ways to hack together the same few commands to make things "work". Grimace, Wry, and the Dragon Slayer Demo are great examples of this. It's a ton of spaghetti code do... more
                    • I didn't really understand what most of those things did - Puckdropper, Sun Oct 10 2021 12:07am
                      until I was introduced to them in college... I may not be super familiar with Perl, but Larry Wall's philosophies changed the way I view certain things. One is if an operation is really common, maybe someone's already got a command for it. So there's RTRIM$, LTRIM$, etc because people needed to r... more
                      • 32 million downloads: But in a rational sense, that's a good philosophy. These days, I find myself looking to see if someone already created a package or library online before attempting to reinvent the wheel myself. I think my first real experience wit... more
                        • Wait, so there's an entire package that just divides by 2 an - Puckdropper, Tue Oct 12 2021 4:57am
                          d tells you if the result has a remainder? (Or shoot, you can just look at the last bit. If 1, not even.) It would kinda make sense in C, where the package could handle different numbers and number types, but isn't a number in JS just a number? (Been a while since I've looked at JS.) One area... more
                          • It relies on another package called "is-odd". This is the entire code for "is-even" From: /*! * is-even * * Copyright (c) 2015, 2017, Jon Schlinkert. * Released under the MIT License. */ 'use strict'; ... more
                            • Wow... You never know what people show they need. - Puckdropper, Sun Oct 24 2021 4:34am
                              I guess that could be a good programming language feature. After all, you're better off with well used libraries than you are writing your own in most cases. (The number of "Apps" on Android that are rewritten versions of other apps--with no more features or even a different design is staggering. ... more
                              • Most languages have a standard library or an equivalent but Javascript doesn't really have an official one. This leads to packages being created to fill this void. Which is fine, but sometimes people hijack these "standard" packages used by many and introduce vulnerabilities or malware into them on ... more
  • Click here to receive daily updates
    "Forces act when not restrained" - Puckdropper