Compilation Problem

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Hiei-
Newbie
Posts: 3
Joined: Tue Jun 13, 2006 8:44 pm

Compilation Problem

Post by Hiei- »

I tried to make a Text-Based RPG like written in one of the tutorials.

The game is running well in QBASIC but don't want to be compiled, cuz of an error :

Internal error near 5F15
0 Warning Error
1 Servere Error

Here's the code :

Code: Select all

REM Test of a RPG in Text Mode
CLS

'Introduction
PRINT "Welcome in the test of a Text Mode RPG by Hiei-!"
INPUT "Please enter your name : ", name$
PRINT "Welcome,"; " "; name$; " "; "!"

0 PRINT

'Place: Outside
PRINT "You're seeing an old castle at the end of the way."
1 PRINT
INPUT "What do you want to do? ", action$
IF action$ = "enter" THEN GOTO 10 ELSE 20
10 PRINT
PRINT "You're actually in the hall."
GOTO 30
20 PRINT
PRINT "Not a valid action. Please enter another command."
PRINT
GOTO 1

'Hall
30 PRINT "This room have a door to the left, another one to the right,"
PRINT "and a last one front of you."
PRINT
31 INPUT "What do you want to do? ", action$

'Left door of the hall
PRINT
IF action$ = "open left door" THEN GOTO 900
IF action$ = "open right door" THEN GOTO 40
IF action$ = "open door front of you" THEN GOTO 50
IF action$ = "go back" THEN GOTO 910
IF action$ <> "open left door" OR action$ <> "open right door" OR action$ <> "open door front of you" OR action$ = "go back" THEN GOTO 32
32 PRINT "Not a valid action. Please enter another command."
PRINT
GOTO 31

'Right door of the hall
40 PRINT "You found a charged pistol in a chest."
PRINT
41 INPUT "What do you want to do? ", action$
IF action$ = "go back" THEN GOTO 43 ELSE GOTO 42
GOTO 30
42 PRINT
PRINT "Not a valid action. Please enter another command."
PRINT
GOTO 41

'Hall (after visited the right door with the charged pistol)
43 PRINT
PRINT "You're back in the hall."
PRINT "You can see three doors from your new sight :"
PRINT
PRINT "- One to the left, leading to the the oustide of the castle"
PRINT "- Another one to the right (the one which was front of you before)"
PRINT "- A last front of you (which was to the left before)"
PRINT
44 INPUT "What do you want to do? ", action$
PRINT
IF action$ = "open left door" THEN GOTO 910
IF action$ = "open right door" THEN GOTO 50
IF action$ = "open door front of you" THEN GOTO 900
IF action$ <> "open left door" OR action$ <> "open right door" OR action$ <> "open door front of you" THEN GOTO 44
45 PRINT "Not a valid action. Please enter another command."
PRINT
GOTO 44

'Front door of the hall
50 PRINT "You're seeing a dragon at the bottom of the room."
PRINT
PRINT "Unfortunately, this dragon doesn't look really kind."
PRINT
51 INPUT "What do you want to do? ", action$
PRINT
IF action$ = "use pistol" THEN GOTO 989
IF action$ = "go back" THEN GOTO 30
IF action$ <> "use pistol" OR action$ <> "go back" THEN GOTO 920

'Game Over Screens
900 PRINT "You're falling in a chamsh, and die in atrocious pains."
PRINT
PRINT "GAME OVER !"
PRINT
INPUT "Do you want to play again ? ", restart$
IF restart$ = "yes" THEN GOTO 999 ELSE END

910 PRINT "You heard a sound just after having tried to open the door."
PRINT
PRINT "Obviously a trap to block any intruder to escape."
PRINT
PRINT "A few seconds later, some spikes appears from the floor..."
PRINT
PRINT "GAME OVER !"
PRINT
INPUT "Do you want to play again ? ", restart$
IF restart$ = "yes" THEN GOTO 999 ELSE END

920 PRINT "The dragon is rushing on you and deadly injure you with his flames."
PRINT
PRINT "Here's what happen when using a unrecognized command before a dragon."
PRINT
PRINT "GAME OVER !"
PRINT
INPUT "Do you want to play again ? ", restart$
IF restart$ = "yes" THEN GOTO 999 ELSE END

989 PRINT "The dragon is afraid because of the pistol's noise and escape."
PRINT
PRINT "You're finding a chest he was hiding, with the jewel you was searching in it."
PRINT
PRINT "Congratulations,"; " "; name$; "!"; " You completed the game!"
END

999 PRINT
PRINT "So, you did a Game Over ?"
PRINT "Good luck for your next try,"; " "; name$; "!"
GOTO 0

END
I know the code sux but I started QBasic yesterday ^^; (but if you have some advices to make it better, I will glady take them ^^)

(The english also sux, I'm french)

Thanks a lot.
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Hiei-,

When you do a compile and link process, besides generating an .EXE for your program, it also generates a list file with a .LST file extension for your program name.

Lookup hex location 5F15 on this .LST file to see the code near where the internal error is occuring. Then rewrite this code another way, because the compiler doesn't like it.

I never use numeric labels anymore, so I'm not sure the label "0" is allowed. You have a line that says: GOTO 0. Maybe change the zero label to something else.

Sorry, but I don't have a DOS machine right now to compile and test your program.

By the way, you do this kind if IF statement several times in your program:

Code: Select all

IF action$ <> "open left door" OR action$ <> "open right door" OR action$ <> "open door front of you" OR action$ = "go back" THEN GOTO 32 
First of all, you get to this instruction because the user DID NOT answer any of the above, so this instruction is not needed at all.
Secondly, if you did need it, it should contain AND between the options, not OR.

*****
Hiei-
Newbie
Posts: 3
Joined: Tue Jun 13, 2006 8:44 pm

Post by Hiei- »

First of all, you get to this instruction because the user DID NOT answer any of the above, so this instruction is not needed at all.
Secondly, if you did need it, it should contain AND between the options, not OR.
Ok for the "AND"

But how am I supposed to notice the user he didn't use a valid command without that o_o ? (If I don't put it, it only answer to the four choices)

My Qbasic 4.5 don't produce a .lst file, just a .obj file o_o

Anyway, you was right, the problem was the lebel 0, it's fixed now, thanks a lot ^^
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Hiei- wrote:
......
But how am I supposed to notice the user he didn't use a valid command without that o_o ? (If I don't put it, it only answer to the four choices)
IF action$ = "open left door" THEN GOTO 900
IF action$ = "open right door" THEN GOTO 40
IF action$ = "open door front of you" THEN GOTO 50
IF action$ = "go back" THEN GOTO 910
....HERE...

If the user enters anything EXCEPT the 4 phrases above, the program will continue to the place where I put "HERE".
At this point, you can send a message about an invalid answer, and do a GOTO back to where you input the phrase.

A simpler way would be to print a little menu like:
1 = open left door
2 = open right door
3 = open door in front of you
4 = go back

Then just ask him to enter 1-4, and the IF's check for 1 to 4.

By the way, I don't understand why your compiler doesn't generate a .LST file.
*****
Hiei-
Newbie
Posts: 3
Joined: Tue Jun 13, 2006 8:44 pm

Post by Hiei- »

moneo wrote:
Hiei- wrote:
......
But how am I supposed to notice the user he didn't use a valid command without that o_o ? (If I don't put it, it only answer to the four choices)
IF action$ = "open left door" THEN GOTO 900
IF action$ = "open right door" THEN GOTO 40
IF action$ = "open door front of you" THEN GOTO 50
IF action$ = "go back" THEN GOTO 910
....HERE...

If the user enters anything EXCEPT the 4 phrases above, the program will continue to the place where I put "HERE".
At this point, you can send a message about an invalid answer, and do a GOTO back to where you input the phrase.

A simpler way would be to print a little menu like:
1 = open left door
2 = open right door
3 = open door in front of you
4 = go back

Then just ask him to enter 1-4, and the IF's check for 1 to 4.

By the way, I don't understand why your compiler doesn't generate a .LST file.
*****
Yeah, I thought about that and i'm putting this method right now.

About the .LST, I don't know, I have QuickBasic 4.0, and it's only make a .obj and a .exe, but it's not very important anyway ^^

Thanks a lot for your help :)
Post Reply