Graphs and what not...

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

User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

You cannot use OPTION as it is a QB keyword for OPTION BASE 1. That is used to start arrays at 1 instead of 0.

What does your Keyboard SUB do now? Not needed...

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

gurmeet:

Did you try to run your code? You should learn how, so you may trouble shoot it when it doesn't do what you want it to.

When I ran it, it stopped, showed the error message "ExpectedL BASE", and highlighted the 2 in the line,
option 2:
The problem here is that a label must be continuous, so, the fix is easy:
option2:

Next, to start you on the road of troubleshooting,, go down one line below the line,
DO: k$ = INKEY$: LOOP UTIL k$ <> ""
and press the F9 key, which creates a BREAKPOINT, or stopping line. That line should have a red background now. The program will execute until it reaches the above DO line.

Now, run the program, and press the down arrow key. The program stops on the next line, and, because it has an F9 key breakpoint, and you will see the code. Now, you can step through the code, one line at a time, by pressing F8 once, each time. You will notice that the program jumps from theline,
IF k$ = "q" THEN END
to the next line,
IF k$ = CHR$(0) + CHR$(80) AND Y <12> 8 THEN
but when you press F8 once more, instead of going to the next line, as you would expect, it jumps to the next line after the line
END IF
Now, we know that the line,
IF k$ = CHR$(0) + CHR$(80) AND Y <12> 8 THEN
must have an error of some kind! By observation, the problem turns out to not quite so simple. It is in the second part,
AND Y <12> 8 THEN
You see, the syntax is wrong! It should be,
AND(Y <12> 8) THEN
But,when you run the code again and use the F8 key, you see that it still jumps past END IF. Aha, if you observe closely, you defined Y as 8, in,
Y - 8
so, you must change the above part to,
AND (Y <12>= 8) THEN
making the whole line,
IF k$ = CHR$(0) + CHR$(80) AND (Y <12>= 8) THEN
Now,your code should not jump doen past END IF.

After you fix the above, please continue to use the F9 and F8 keys to trouble shoot some more, until you get that part of your code working properly. Then, you will be ready to post your next question, on a particular line that you find doesn't do what you think it should.

If you are willing to learn by doing the above, I, and others, will be happy to continue to guide you through your proyect.
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Come on man!

Post by burger2227 »

The LEAST you should do is run your code before posting it! Or is this some kind of a joke to keep cheaters away LOL.

Then Open the module with Notepad and paste it here once it is working.

I bet he never finds this page either LOL.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
gurmeet
Newbie
Posts: 8
Joined: Sat Mar 29, 2008 2:54 pm

Post by gurmeet »

Thank you so much Ralph. I've learned a lot through your explanations. Uhm, as for option 2, it still gives me the Base error thing. Although I'm done my project, I'm not sure how to fix the option 2 thing and nor was my Menu ready in time so I handed in 3 choices instead of 4.

Here's where I still get the error, but I understand the "IF k$ = CHR$(0) + CHR$(80) AND (Y <12>= 8) THEN" correction so far. =) Thank you.

Code: Select all

CLS
LOCATE 4, 10
COLOR 9
PRINT "What Would You Like To Do?"

LOCATE 5, 10
PRINT "Use The Arrow Keys To Move Up And Down On The Menu"

LOCATE 17, 10
COLOR 9
PRINT "Press q To Exit The Menu"
DIM a$(5)
a$(1) = "Watch A Malfunctioning Radar"
a$(2) = "See The Function Of Sine On Peculiar Objects"
a$(3) = "Go To Quadratic Function"
a$(4) = "Go To Linear Function"
Y = 8
x = 10
C = 1

COLOR 15

REM COLOR OF CHOICE IS HIGHLITE

HIGHLITE = 9

FOR M = 1 TO 4
LOCATE Y, x
PRINT a$(M)
Y = Y + 2
NEXT M

Y = 8
choice:
DO: k$ = INKEY$: LOOP UNTIL k$ <> ""
IF k$ = "q" THEN END
IF k$ = CHR$(0) + CHR$(80) AND (Y <12>= 8) THEN
Y = Y - 2
C = C - 1
COLOR HIGHLITE
LOCATE Y, x
PRINT a$(C)
COLOR 15
LOCATE Y + 2, x
PRINT a$(C + 1)
END IF

IF k$ = CHR$(13) AND C = 1 THEN GOTO option1
IF k$ = CHR$(13) AND C = 2 THEN GOTO option2
IF k$ = CHR$(13) AND C = 3 THEN GOTO drawquadratic
IF k$ = CHR$(13) AND C = 4 THEN GOTO option4
GOTO choice
END

KEYBOARD:
k$ = INKEY$
RETURN

option1:
CLS
SCREEN 13

CIRCLE (156, 95), 110, 4
CIRCLE (157, 95), 2, 4
PAINT (158, 95), 2, 4
FOR x = -6.28 TO 6.28 STEP .1
CIRCLE (156, 95), 110, 4, x, x + .01
GOSUB waiting
CIRCLE (156, 95), 110, 2, x, x + .01
NEXT x

LINE (160, 95)-(265, 95), 4

END

waiting:
FOR t = 1 TO 50000
NEXT t
RETURN

END

option 2:


drawquadratic:
PRINT "lol:P"
END

option4:
CLS
PRINT "4"
END

Thanks for the help guys. Appreciated. I'm going to make a game next, I'll be learning the basics and as soon as I have something worthy of corrections I'll let you guys know. :T
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

As to "the option 2 thing". It's quite simple. Labels cannot have spaces (empty places), so, just change it from
option 2:
to
option2:
See the difference?

EDITED ON April 18, 2008:
In a previous post, I wrote, as correct code, the partial line:
AND(Y <12> THEN
WRONG! Please change it to:
AND Y <12> 8 THEN
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

gurmeet:

I will try to help you after you fix your option2 label, as you still haven't fixed it! Why haven't you addressed this problem? If you do as we have asked you more than once, "Run your program", you would have found that to be a problem, and would have tried to fix it.

Remember, we all here are trying to help you, but only if you show the proper willingness to help yourself. We're like the gods, somewhat, as in the old Greek proverb, "The gods help those who help themselves".
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
Post Reply