Can Someone Tell Me What Is Wrong With This Code?
#1
Posted 03 May 2004 - 06:04 AM
If Getkey=79
Then "ONE" _ (_ means display)
IfEnd
okay another question, if i want to link 2 programs together, how do i do it? there is a main program, say, Program A and i would like to use some coding from another program say Program B and then resume executing program A again.
My email is chigan_4444 AT yahoo.com. pls help!
#2
Posted 03 May 2004 - 07:33 AM
as for calling a program use the Prgm command:
ex:
Prgm "B"
use Return to go back to the program that called it. (it goes back automatically at the end of the program)
#3
Posted 03 May 2004 - 08:53 AM
GetKey=79=>"one"_
( _ = Display and => is found here: Shift' />VARS' />F3' /> menu )
#4
Posted 03 May 2004 - 10:33 AM
Also, if you do not put Return in the second program, it will automatically return at the end. A bit of useful trivia, sometimes it's hard to find a place to put Return...
Another question: You can get the calc to draw a tangent on a graph but can you get it to show the gradient (or equation)?
#5
Posted 03 May 2004 - 10:46 AM
Do:0->A:Getkey->A Lpwhile A=0
that will cause the program to wait then you could extemd it for a menu:
Do:0->A:Getkey->A LpWhile ((A=79) Or (A=69) Or (A=59) Or (A=49) Or (A=39) Or (A=29))=0
that will cause the calc to wait until one of the given keys is pressed, you could then use an If ~ Then ~ Else ~ IfEnd statement
If A=79 Then ClrText 'stuf to do IfEnd If A=69 Then ClrText 'stuf to do IfEnd If A=59 Then ClrText 'stuf to do IfEnd
that is how i do my menus, the Lpwhile function is courtesy of Betoe
#6
Posted 03 May 2004 - 01:42 PM
in the subprog, you use Return to return to the main prog, where the subprog was called. at the end of the subprog, it returns automatically to the main prog.
/!\ you can have subprog, subsubprog, subsubsubprog, ... but there is a limit, at a moment you'll have Ne Error, so never go back to the main program with the Prog command, but use Return
#7
Posted 03 May 2004 - 02:01 PM
no. Only the calcs of the A(FX) series (and probably the classpad) can do this.Another question: You can get the calc to draw a tangent on a graph but can you get it to show the gradient (or equation)?
#8
Posted 04 May 2004 - 09:07 AM
Oh well, looks like I'll have to learn calculus... Alright, the shortest and fastest way to:no. Only the calcs of the A(FX) series (and probably the classpad) can do this.
Pause and wait for EXE to be pressed:
Do:LpWhile Getkey=/=31 (it fits perfectly on one line)
Pause and wait for any key to be pressed:
Do Getkey LpWhile Ans=0 (use a variable if you want)
Pause and wait for any key but EXE to be pressed
Do Getkey LpWhile Ans=0 Or Ans=31 (useful for pausing games)
(This may be in CK's notes template) Pause at menu screen:
Do Getkey=79=>Goto 1 Getkey=69=>Goto 2 Getkey=59=>Goto 3 Getkey=49=>Goto 4 Getkey=39=>Goto 5 LpWhile Getkey=/=29 (and then whatever you want)
I think he wants us to e-mail him.
#9
Posted 04 May 2004 - 03:44 PM
I think he wants us to e-mail him.
i have sent him an email saying to check the forum, as many people have replied to his post.
#10
Posted 10 May 2004 - 06:24 AM
Lbl 0
(the coding... about 100 lines)
Goto 0
how do i get program B to jump back to a label in Program A? i don't want program A to start again. Say i have a Lbl B in Program A and 15 lines below that i ask the calculator to load program B, after i finish program B, i want the calculator to go back to the Label B in Program A.
I tried using getkey in a loop, this is the code.
Lbl 0
ClrText
Getkey=79=>Text 1,1, "Hello"
Getkey=69=>Text 1,1,"Goodbye"
Goto 0
And when i try out the code, it gets irritating as the calculator keeps reloading the code again.
#11
Posted 10 May 2004 - 08:54 AM
As for jumping labels, I have tried to do that before and yes, I still need to, but I never found a good way to do so. Remember, using the Return function doesn't restart the program, it goes back to where it left off. The Goto you are using is going back to the first label, you have to simply use Return. If you use a part of a program a lot or need to get it first, put it first in the program, assign it as a function or create a new program...
#12
Posted 10 May 2004 - 09:36 AM
#13
Posted 10 May 2004 - 07:02 PM
#14
Posted 10 May 2004 - 11:19 PM
anyway, here is an example of a program that calls another program, then based on the results goes to a specific label:
Program "A"
Lbl 0 ClrText "MAIN MENU" "1- HI" "2- HELLO" "3- QUIT" Prgm "B" r=72=>Goto 1 r=62=>Goto 2 r=52=>Stop Goto 0 Lbl 1 "HI" Prgm "B" Goto 0 Lbl 2 "HELLO" Prgm "B" Goto 0
Program "B"
Do Getkey->r LpWhile r=0 Return
I like using the r variable when sending data from one program to another, its easy to remember and makes sense for that use.
#15
Posted 11 May 2004 - 12:22 AM
You know this is the basic Physics formula for displacement,velocity and time. how can i create a program that can calculate any one of those variables if i have the other two? Let's say i have v and s, how do i calculate t? another case, if i have t and s how to calculate v?
#16
Posted 11 May 2004 - 12:53 AM
#17
Posted 11 May 2004 - 04:46 AM
"Unknown Value:" "[F1]=s" "[F2]=v" "[F3]=t" DO:Getkey->R:While R<>79 and R <> 69 and R <> 59 If R=79 THEN "V="?-V "T="?-T VT_ ENDIf If R=69 THEN "S="?->S "T="?->T S/T_ IfEnd If R=59 THEN "S="?->S "V="`?->V S/V_ IfEnd
That should do it.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users