I haven't been able to find a simple solution to this problem. I have a program that displays an image, then it waits for 2 before showing the next one. It goes for a loop, so I decided to use get key so the user can quit without using ON. However, the only time the calc can check to see if getKey=45 is when it is not in the paused wait. How can I fix this?

Code:

Repeat A=45
Axes off
getKey->A
BackgroundOn 1
Wait 2
BackgroundOn 2
Wait 2
BackgroundOn 3
Wait 2
BackgroundOn 4
Wait 2
End
21tmccauley wrote:
I haven't been able to find a simple solution to this problem. I have a program that displays an image, then it waits for 2 before showing the next one. It goes for a loop, so I decided to use get key so the user can quit without using ON. However, the only time the calc can check to see if getKey=45 is when it is not in the paused wait. How can I fix this?

Code:

Repeat A=45
Axes off
getKey->A
BackgroundOn 1
Wait 2
BackgroundOn 2
Wait 2
BackgroundOn 3
Wait 2
BackgroundOn 4
Wait 2
End


Add more getKey->A's, as in one after each thing, and everywhere. It's stupid, but it works.
jcgter777 wrote:

Add more getKey->A's, as in one after each thing, and everywhere. It's stupid, but it works.

I tried this, but it still won't let the clear button end the program.

Code:

Repeat A=45
AxesOff
getKey→A
BackgroundOn 1
getKey→A
DispGraph
getKey→A
Wait 2
getKey→A
BackgroundOn 4
getKey→A
Wait 2
getKey→A
BackgroundOn 5
getKey→A
Wait 2
getKey→A
BackgroundOn 7
getKey→A
Wait 2
getKey→A
End
Ooooof. Stupid me. You need an If A=45 statement at the end telling it what to do when clear is pressed.
jcgter777 wrote:
Ooooof. Stupid me. You need an If A=45 statement at the end telling it what to do when clear is pressed.

Do you mean like this?

Code:

Repeat A=45
AxesOff
getKey→A
BackgroundOn 1
getKey→A
DispGraph
getKey→A
Wait 2
getKey→A
BackgroundOn 4
getKey→A
Wait 2
getKey→A
BackgroundOn 5
getKey→A
Wait 2
getKey→A
BackgroundOn 7
getKey→A
Wait 2
getKey→A
End
If A=45
Return

This isn't working, and neither does the same bit before the end.
All If statements have to be closed with an 'End'. Use ClrHome/Stop instead of Return. (Return is for returning from another subprogram)
jcgter777 wrote:
All If statements have to be closed with an 'End'. Use ClrHome/Stop instead of Return. (Return is for returning from another subprogram)

I thought that 'End' was only needed if the if statement was more than two lines. Either way, I modified it to address both of these points, and "Clear" still has no effect,

Code:

Repeat A=45
AxesOff
getKey→A
BackgroundOn 1
getKey→A
DispGraph
getKey→A
Wait 2
getKey→A
BackgroundOn 4
getKey→A
Wait 2
getKey→A
BackgroundOn 5
getKey→A
Wait 2
getKey→A
BackgroundOn 7
getKey→A
Wait 2
getKey→A
If A=45
Stop
End
If A=45
Stop
End
21tmccauley wrote:
jcgter777 wrote:
All If statements have to be closed with an 'End'. Use ClrHome/Stop instead of Return. (Return is for returning from another subprogram)

I thought that 'End' was only needed if the if statement was more than two lines. Either way, I modified it to address both of these points, and "Clear" still has no effect,

Code:

Repeat A=45
AxesOff
getKey→A
BackgroundOn 1
getKey→A
DispGraph
getKey→A
Wait 2
getKey→A
BackgroundOn 4
getKey→A
Wait 2
getKey→A
BackgroundOn 5
getKey→A
Wait 2
getKey→A
BackgroundOn 7
getKey→A
Wait 2
getKey→A
If A=45
Stop
End
If A=45
Stop
End


Try this:

Code:

ClrHome
AxesOff
DispGraph
While A!=45
BackgroundOn 1
getKey->K
Wait 2
getKey->K
BackgroundOn 2
getKey->K
Wait 2
getKey->K
BackgroundOn 3
getKey->K
End

ClrHome
Stop
If statements only need an End if they have are an If-Then. If-Then can span multiple lines.
Try something like this:

Code:

Repeat A=45

0->B
Repeat B=20 or A=45
B+1->B
getKey->A
End
BackgroundOn 1

0->B
Repeat B=20 or A=45
B+1->B
getKey->A
End
BackgroundOn 2

0->B
Repeat B=20 or A=45
B+1->B
getKey->A
End
BackgroundOn 3

getKey->A


Edit the number B is compared to to make your delay longer or shorter.
I tried modifying to meet what dankcaclutaltorbro said, but now when you press clear, all it does is move on to the next image, not quit.

Code:

Repeat A=45
AxesOff
0->B
   Repeat B=75 or A=45
      DispGraph
B+1->B
getKey->A
End
BackgroundOn 1

0->B
   Repeat B=75 or A=45
      DispGraph
B+1->B
getKey->A
End
BackgroundOn 4

0->B
   Repeat B=75 or A=45
      DispGraph
B+1->B
getKey->A
End
BackgroundOn 5

0->B
   Repeat B=75 or A=45
      DispGraph
B+1->B
getKey->A
End
BackgroundOn 7

   getKey->A
End
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement