I've been working with the Qbasic BootCamp tut series, and i've read 4 pages and did the assignments. Now i'd like to take a break from learning and try to use some of it on a project.
One problem i had from the start is reading from files. From what the tut says, i can only read one line, or read numerical data into an array. What i needed to do was read an entire SUB from a file.
I've got a fair-sized graphic designed (one of what is going to be quite a few of them), and it takes up not a few lines, and i don't want the main program flooded with all that. It would be much easier to just write a txt file and read it into it, but i just can't seem to figure out how that works.
I used to use a program called DarkBASIC that had a command called APPEND, then i just called the SUB name and it read all the commands, but i don't think qbasic has anything like that, does it?
If not, is there anything else i can do here? This is all assuming SUBS use up the size limit, which i don't know if it does or not.
Reading from Files?
-
- Veteran
- Posts: 109
- Joined: Thu Feb 10, 2005 12:38 pm
It is possible to create two files, and compile them together, but it is complicated, a much easier way is to change to FreeBasic
-
- Veteran
- Posts: 109
- Joined: Thu Feb 10, 2005 12:38 pm
Actually, $INCLUDE is not a library command, it's what Basic calls a metacommand. It provides a nice, simple way for programs to be able to share some common code. Most languages have similar facilities. COBOL calls these "copyfiles".SCC wrote:......
Anyways, I figured it out '$INCLUDE: 'code.txt'
Guess it's a library command, but it worked pretty good here, hehe.
An INCLUDE inserts the entire block of code from the specified text file. There are some restrictions as to what code can be included.
Some languages have MACRO libraries which allow you to insert a block of customized source code based on provided parameters.
Other languages, including QuickBasic, allow you include a function or a SUB from a library. Only the call to the function or SUB actually appears in your source code, and the required code is LINKED into your executable program. That is, you don't actually see it as part of your source code.
Regards..... Moneo
For crying out loud, Ray, you sound like a Jesus freak! You're like an evangelist who keeps pounding us with FreeBasic. It can get really annoying. Don't you have anything original to share in your posts?RayBritton wrote:fb is the modern version of qb, there are almost no differences
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
good job i'm the same way....i want to learn all i can from qbSCC wrote:I'd rather keep learning in Qbasic for the moment at least, this is the first time i'm actually retaining all this info and getting some programs working.
Anyways, I figured it out '$INCLUDE: 'code.txt'
Guess it's a library command, but it worked pretty good here, hehe.
then i'll try something else...i still have VERY far to go..