Page 1 of 1

Compiling Errors...

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

Posted: Sat Apr 16, 2005 5:52 am
by Dr_Davenstein
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. ;)

Posted: Sun Apr 17, 2005 5:18 pm
by Darksword X
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?

Posted: Sun Apr 17, 2005 11:00 pm
by Dr_Davenstein
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?

Posted: Mon Apr 18, 2005 2:54 am
by Darksword X
Sort of... :(
Can you tell me on how to use them to replace GOTO?

Posted: Mon Apr 18, 2005 7:25 am
by Dr_Davenstein
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. ;)

Posted: Thu Apr 21, 2005 9:45 pm
by DSX-School
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)

Posted: Fri Apr 22, 2005 12:47 am
by buff1
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.

Ah~~~Chooooooooo

Posted: Tue May 03, 2005 4:19 pm
by defrag
Sorry I only speak B.A.S.I.C.!

Posted: Tue Feb 21, 2006 1:56 pm
by a programmer
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