Compiling Errors...
Moderators:Administrator, Global Moderator
-
- Newbie
- Posts:3
- Joined:Sat Apr 16, 2005 3:09 am
Okay... I am trying to compile a program into a *.exe file and have come across some errors in Qbasic. I have used versions 3, 4.5, and 7, and got an error message from each one. Qbasic 3 says "Subprogram Error" and the other two versions just say that a bad error occurred. I don't understand what the error messages mean, as they are rather unspecific.
I'm probably just encountering this because I am new to Qbasic, but it could be anything. I also tried to use the PLAY and SOUND commands, which work fine when you are running the program. The program runs fine, but compiles with a lot of trouble... Is there anyone here who has run into the same problem, or knows how to fix it? Your help would be greatly appreciated.
I'm probably just encountering this because I am new to Qbasic, but it could be anything. I also tried to use the PLAY and SOUND commands, which work fine when you are running the program. The program runs fine, but compiles with a lot of trouble... Is there anyone here who has run into the same problem, or knows how to fix it? Your help would be greatly appreciated.
-Darksword X
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
Are you using alot of GOTO or GOSUB statements? Is it a stack overflow error? Are you using any libraries? What operating system are you running? Post the exact error message that you get, if possible.
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!
-
- Newbie
- Posts:3
- Joined:Sat Apr 16, 2005 3:09 am
Yes, I am using a lot of GOTO statements. (possibly 20-ish) I am not sure, however, how many is too many.
The error message came up as
"Internal error near 5FA7"
"43197 bytes available"
"40768 bytes free"
"0 warning error(s)"
"1 severe error(s)"
(qb4.5 and qb7)
In qbasic 3, It just said "Subprogram Error."
Can you give me any help on any of this?
The error message came up as
"Internal error near 5FA7"
"43197 bytes available"
"40768 bytes free"
"0 warning error(s)"
"1 severe error(s)"
(qb4.5 and qb7)
In qbasic 3, It just said "Subprogram Error."
Can you give me any help on any of this?
-Darksword X
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
If it's possible to use SUB's/FUNCTION's instead of GOTO's, you should do it. Do you know how to use a subroutine/function?
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!
-
- Newbie
- Posts:3
- Joined:Sat Apr 16, 2005 3:09 am
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
Well, there is a smal difference between a sub and a function. A sub will do something, but not return a value. On the other hand, a function will return a value. Check this out...
This is an example of a FUNCTION:
Here's an example of a SUB:
Just rum them in QB, and you'll see what the difference is between them.
This is an example of a FUNCTION:
Code: Select all
DECLARE FUNCTION Distance! (X1 AS SINGLE, Y1 AS SINGLE, X2 AS SINGLE, Y2 AS SINGLE)
PRINT Distance!(50, 80, 65, 95)
FUNCTION Distance! (X1 AS SINGLE, Y1 AS SINGLE, X2 AS SINGLE, Y2 AS SINGLE)
Distance! = SQR((Y2 - Y1) ^ 2 + (X2 - X1) ^ 2)
END FUNCTION
Here's an example of a SUB:
Code: Select all
DECLARE SUB PrintStuff (Array() AS INTEGER, Start AS INTEGER, Finish AS INTEGER)
DIM MyArr(1 TO 5000) AS INTEGER
FOR i = 1 TO 5000
MyArr(i) = INT(RND * 28000)
NEXT
PrintStuff MyArr(), 50, 60
SUB PrintStuff (Array() AS INTEGER, Start AS INTEGER, Finish AS INTEGER)
FOR i = Start TO Finish
PRINT Array(i)
NEXT
END SUB
Just rum them in QB, and you'll see what the difference is between them.
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!
If you end up with a lot of subs and functions once you replace things,
you might think about saving some bas files with just subs/functions in them - no main module code.
Then open the main program (that doesnt have these subs/functions in it)
then use the load option to load the other bas files. QuickBasic will make a
mak file so that the next time you open the main program, all the bas files
etc are loaded.
When you compile, each will be compiled individually then linked together.
letting you have 64k for each bas file (actually somewhat less).
Another thing that might cause you problems is long line lengths.
Try to keep the line length under 100 characters if at all possible.
This might mean breaking up multi-line ifs, for example, that check lots of
things.
you might think about saving some bas files with just subs/functions in them - no main module code.
Then open the main program (that doesnt have these subs/functions in it)
then use the load option to load the other bas files. QuickBasic will make a
mak file so that the next time you open the main program, all the bas files
etc are loaded.
When you compile, each will be compiled individually then linked together.
letting you have 64k for each bas file (actually somewhat less).
Another thing that might cause you problems is long line lengths.
Try to keep the line length under 100 characters if at all possible.
This might mean breaking up multi-line ifs, for example, that check lots of
things.