Compiling Errors...

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Darksword X
Newbie
Posts:3
Joined:Sat Apr 16, 2005 3:09 am
Compiling Errors...

Post by Darksword X » Sat Apr 16, 2005 3:20 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.
-Darksword X

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Sat Apr 16, 2005 5:52 am

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!

Darksword X
Newbie
Posts:3
Joined:Sat Apr 16, 2005 3:09 am

Post by Darksword X » Sun Apr 17, 2005 5:18 pm

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?
-Darksword X

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Sun Apr 17, 2005 11:00 pm

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!

Darksword X
Newbie
Posts:3
Joined:Sat Apr 16, 2005 3:09 am

Post by Darksword X » Mon Apr 18, 2005 2:54 am

Sort of... :(
Can you tell me on how to use them to replace GOTO?
-Darksword X

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Mon Apr 18, 2005 7:25 am

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:

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!

DSX-School

Post by DSX-School » Thu Apr 21, 2005 9:45 pm

Hey, thanx. I'll try to do one of the above... The only problem is that I'll have to change a lot of code

THX!


(This is from my school, used to prevent spyware tracking of my real one)

buff1

Post by buff1 » Fri Apr 22, 2005 12:47 am

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.

defrag

Ah~~~Chooooooooo

Post by defrag » Tue May 03, 2005 4:19 pm

Sorry I only speak B.A.S.I.C.!

a programmer

Post by a programmer » Tue Feb 21, 2006 1:56 pm

Dr_Davenstein is correct. I had the same problem of 5FA7 showing up. I changed all my games' sections into SUBs and now it compiles. I highly recommend Dr_Davenstein for all of your basic problems

Post Reply