Jump to content



Photo
- - - - -

Can Someone Tell Me What Is Wrong With This Code?


  • Please log in to reply
16 replies to this topic

#1 renjer

renjer

    Casio Fan

  • Members
  • PipPip
  • 41 posts
  • Location:Perth, WA
  • Interests:BASIC programming (would like to try MLC but I have no AFX), computer games

  • Calculators:
    cfx-9850gb plus

Posted 03 May 2004 - 06:04 AM

recently i entered in this code into my calculator(the program menu), the casio graphics calculator cfx-9850gb and it couldn't work, can someone pls help me out?

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 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 03 May 2004 - 07:33 AM

by couldnt work do you mean it gave an error? that code seems fine, perhaps the problem is not right there but only shows up there.

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 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking & Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool & Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 03 May 2004 - 08:53 AM

you could shorten the code you could write:

GetKey=79=>"one"_

( _ = Display and => is found here: <span class=Shift' /><span class=VARS' /><span class=F3' />F3 menu )

#4 genesis

genesis

    UCF BASIC Programming Runner Up

  • Super Member
  • PipPipPipPip
  • 281 posts
  • Location:Perth, Australia
  • Interests:Speaking German, computers, defending CFX calculators...

  • Calculators:
    CFX 9850 GB+

Posted 03 May 2004 - 10:33 AM

Is it in a loop? If it isn't, it won't work and if it is then Getkey will be 31 because the EXE key is pressed to resume after Disp (and it will be returned unless the user lets go of the key immediately). Remember, Getkey=0 doesn't work.

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 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 03 May 2004 - 10:46 AM

here is the code i use:

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 Overlord

Overlord

    Casio Technician

  • Moderator
  • PipPipPipPipPipPip
  • 355 posts
  • Gender:Male
  • Location:Brussels - Belgium
  • Interests:Math Researcher

  • Calculators:
    My head - C300 OS 3.00 - G100 Rom 1.02 - G65 - G60 - G25

Posted 03 May 2004 - 01:42 PM

to call a prog it's Prog "xxxx" where xxxx is the prog's name

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 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 03 May 2004 - 02:01 PM

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)?

no. Only the calcs of the A(FX) series (and probably the classpad) can do this.

#8 genesis

genesis

    UCF BASIC Programming Runner Up

  • Super Member
  • PipPipPipPip
  • 281 posts
  • Location:Perth, Australia
  • Interests:Speaking German, computers, defending CFX calculators...

  • Calculators:
    CFX 9850 GB+

Posted 04 May 2004 - 09:07 AM

no. Only the calcs of the A(FX) series (and probably the classpad) can do this.

Oh well, looks like I'll have to learn calculus... ;) Alright, the shortest and fastest way to:

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. :roflol:

#9 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 04 May 2004 - 03:44 PM

I think he wants us to e-mail him. :rofl:


i have sent him an email saying to check the forum, as many people have replied to his post.

#10 renjer

renjer

    Casio Fan

  • Members
  • PipPip
  • 41 posts
  • Location:Perth, WA
  • Interests:BASIC programming (would like to try MLC but I have no AFX), computer games

  • Calculators:
    cfx-9850gb plus

Posted 10 May 2004 - 06:24 AM

Thanks guys, but now i have another question, see it's like if i have a Label and Goto command, there will still be the Go Error.

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 genesis

genesis

    UCF BASIC Programming Runner Up

  • Super Member
  • PipPipPipPip
  • 281 posts
  • Location:Perth, Australia
  • Interests:Speaking German, computers, defending CFX calculators...

  • Calculators:
    CFX 9850 GB+

Posted 10 May 2004 - 08:54 AM

Firstly, if you are getting Go Errors, like I always did at one stage, it means you must check your program thoroughly for errors (the so called 'debugging' system isn't very informative) and make sure all the quotations "" are closed.

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... :lol2:

#12 renjer

renjer

    Casio Fan

  • Members
  • PipPip
  • 41 posts
  • Location:Perth, WA
  • Interests:BASIC programming (would like to try MLC but I have no AFX), computer games

  • Calculators:
    cfx-9850gb plus

Posted 10 May 2004 - 09:36 AM

is there any books or sites out there that i can learn programming for the casio cfx-9850 gb +?

#13 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 10 May 2004 - 07:02 PM

no, but if yo search the forum for Casio Basic Tutorial, that has quite a lot of information in it, it is writen by crimson.

#14 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 10 May 2004 - 11:19 PM

but still not finished :(

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 renjer

renjer

    Casio Fan

  • Members
  • PipPip
  • 41 posts
  • Location:Perth, WA
  • Interests:BASIC programming (would like to try MLC but I have no AFX), computer games

  • Calculators:
    cfx-9850gb plus

Posted 11 May 2004 - 12:22 AM

s=vt

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 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 11 May 2004 - 12:53 AM

use the solver on your calc...

#17 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

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