Page 1 of 2

Graphs and what not...

Posted: Sat Mar 29, 2008 3:03 pm
by gurmeet
EDIT: I'm almost done. :)

Homework

Posted: Sat Mar 29, 2008 4:19 pm
by burger2227
We do not do homework, but if you post some of your code and have certain problems, we can help. To copy your code from QB, save the program code as text readable. Open the QB BAS file with Edit from the Right click mouse Menu. Should open in Notepad.

Copy and paste to the post using the

Code: Select all

 Your code 
button in the menu here. That should format the code properly.

Ted

Re: Homework

Posted: Sun Mar 30, 2008 3:38 pm
by Mac
burger2227 wrote:We do not do homework
True, gurmeet, and don't bother going elsewhere. Nobody will
do your homework. QBasic programmers are honorable students.

Mac

Sorry about that.

Posted: Sun Mar 30, 2008 3:49 pm
by gurmeet
EDIT: ALMOST DONE!

Posted: Sun Mar 30, 2008 5:00 pm
by Ralph
Gurmeet:

You are only plotting the points with X = -10, -9, -8,...8, 9, 10, that is, only 21 points, each separated by a distance dX = 1. Make your FOR/TO using a STEP 0.01, so you'll get a whole lot of points plotted, making the result look like a continuous curve.

HUH?

Posted: Sun Mar 30, 2008 6:37 pm
by burger2227
You can plot decimal values all you want with PSET, but INTEGERs are the only ones shown. Grahics functions plot Integer pixel positions. There is no such thing as half a pixel!

Don't use STEP point anything for x. All you will see are the positive values anyhow! SIN may work for the y position, but it converts to only Integers also.

Ted

Posted: Sun Mar 30, 2008 7:20 pm
by gurmeet
EDIT: ALMOST DONE!

Posted: Sun Mar 30, 2008 10:36 pm
by Ralph
Ted and gurmeet I apologize for posting wrong information! :oops:

Gurmeet: Thank you for posting your code. Here are some of the things that I find need fixing:

1. The first line your subtoutine keyboard will not work! One fix could be:
k$="":WHILE k$="": k$=inkey$:WEND
That line will first make sure the string variable k$ starts out as a blank (""); then, it creates the WHILE/WEND loop, and it will stay looping until you press a key, which then allows k$ to read from the inkey$ function.

2. You should add a fourth line to your menu, instructing the user to press the Q key to quit. But, you must consider what will happen if the user presses the Q key without using the Shift key, which will give a lower case q.

3. Your code shows a respond to the UP key- but, your menu doesn't instruct the user what the upper key is supposed to do.

There are a few other things to comment on, but, I think you are going to first have to try to think through each move you want to make, then code that move, all one step at a time, before your program can do much more. So, try to use comments before each part of your code, to describe what you intend to have happen; then, if you can't seem to make the code work, at least we will know if your logic is correct.

Posted: Mon Mar 31, 2008 4:42 am
by Mac
Ralph wrote:Here are some of the things that I find need fixing:
Nice work, you guys! Now that is how to help. I would chime in, but things are working out without me just fine.

Mac

Posted: Mon Mar 31, 2008 10:02 am
by TmEE
Optimization :

WHILE INP(&H60) > 127: blablablablabla : WEND

I have some code that graphs some equation... I'll look for it, maybe you find it useful.

EDIT : Seems I've lost the code...

Posted: Mon Mar 31, 2008 7:04 pm
by burger2227
Change the keyboard routine to wait for a keypress. That can easily be done using an INKEY$ loop.

Code: Select all

DO: k$ = INKEY$: LOOP UNTIL k$ <> ""
Using INP(60), all values over 128 are release codes only. INKEY$ is usually a better choice for simple menus.

Ted

Posted: Tue Apr 01, 2008 10:08 pm
by gurmeet
EDIT: ALMOST DONE!

Posted: Wed Apr 02, 2008 4:23 pm
by gurmeet
Since my classmates have the same project to do, I heard some of them talking about stealing some info off of this site. They said they've found some info about the project and I'm sure they're talking about my post. Is there any way we can secure my posts from non-members? It'll be really helpful, because I'm afraid the students that get higher than me might copy and then when we present they will be the one that the teacher will believe. :(

Gurmeet and "Stealing code"

Posted: Wed Apr 02, 2008 10:45 pm
by Ralph
I'm afraid that anyone can come to this and any other site and copy whatever is available. That is also one of the reasons that we don't like to try to completely solve homework; rather, we encourage collaborative efforts, and try to indicate the "how and why", rather than the solution.

You should have a headstart on the possible copiers, since you have writen your code. If you undestand what the code is doing, or is supposed to be doing, you should only post that part of code that is not working properly, and not all the code. In that manner, youwon't have to worry about others copying your finished work.

Posted: Thu Apr 03, 2008 12:29 am
by sid6.7
gurmeet wrote:Since my classmates have the same project to do, I heard some of them talking about stealing some info off of this site. They said they've found some info about the project and I'm sure they're talking about my post. Is there any way we can secure my posts from non-members? It'll be really helpful, because I'm afraid the students that get higher than me might copy and then when we present they will be the one that the teacher will believe. :(
well if your professor has questions about who knew what
direct him here...

LOL

Posted: Thu Apr 03, 2008 1:16 am
by burger2227
You went from a cheater to a hider pretty quick!

Don't worry about other's copying your code. If they do, then the teacher will suspect something. Also be sure to use code that fits your experience level in the class. Teachers often can spot code that is more expert than the pupil can normally do.

As for the division error check your domain variable <> 0. If it is, either exit the sub or find another way to correct it. Often it helps if you print the value when a program is running. Locate it somewhere visible at all times while troubleshooting. Debug does not work well in XP.

Ted

Posted: Thu Apr 03, 2008 7:03 pm
by gurmeet
I'm trying to put another option on the menu, it lets me have it on the screen but when I scroll up and down with the Arrow Keys, I can only highlight the first three. I'm unsure of how since the code was given by our teacher.

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

Posted: Fri Apr 04, 2008 4:26 pm
by Ralph
gurmeet: I don't know what version of qb you have, but, in my QuickBASIC Version 4.5, as soon as I try to run your code, it gives me an error message, "Label not defined", and stops on your line,

IF k$ = CHR$(13 AND C = 2 THEN GOTO option2

Note that GOTO option2 requires a label option2, which shold be at the beginning of some line, and all by itself, written as

option2:

Since your code lacks this label, the program in QuickBASIC, Version 4.5, will not run. And, if it runs in your version of QB, it should crash as soon as you choose option2.

Your code also lacks the labels Drawquadratic: and option4:, both supposed options for the user.

Once you have posted your corrected code, I will be happy to try to see if I can run it and, if I have a problem, report it to you, for further correction.

YOU ARE DONE?

Posted: Fri Apr 04, 2008 9:35 pm
by burger2227
Deleted all of his posts because he does not want any other CHEATERS in his class to see them..........

Did you ever consider that others read these threads so that we don't have to reply fifty times? Some people read these threads for tips and ideas.

Ted

Posted: Sat Apr 05, 2008 12:15 pm
by gurmeet
That was really friendly, Ted. Thanks.


Ralph, sorry about that I forgot to fix it =(

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:
cls
? "2"
end

drawquadratic:
? "lol:P"
end

option4:
cls
? "4"
end
There you go.