This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Author Message
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 18 Feb 2004 09:01:10 pm    Post subject:

I tried

Repeat Ans=105
For(X,1,100 (will shorten loop when figured out)
End

I need so if you dont press 105 in that for loop it does something and if you do it goes to something, but how could that work, and dont tell me to RTFM. It should be BTFM (Burn the f****** manual). When you get the SE it gives you a manual about 20 pages long, and thats it. :(

edit: when I mean shorten loop when figured out I mean when I figured out what the program will be like.


Last edited by Guest on 18 Feb 2004 09:04:41 pm; edited 1 time in total
Back to top
Jedd
1980 Pong World Champion


Elite


Joined: 18 Nov 2003
Posts: 823

Posted: 18 Feb 2004 09:34:07 pm    Post subject:

Um, your code needs a getkey. I think what you wanted to do is this:

0
Repeat Ans=105
For(X,1,100
End
getkey
End

But I would just do this:

Repeat getkey=105
(whatever)
End
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 18 Feb 2004 10:06:56 pm    Post subject:


Code:
100->A //how long the for( loop would be
Repeat not(A
A-1->A
If getKey=105 //check for enter
Goto AA //leave loop
End
Goto BB //user didnt press enter, A=0
Lbl AA
End //have to close the loop we jumped out of
Lbl BB //have to skip then End for jumping out of the loop or we'd get an error
If not(A
Then
//user DIDNT press enter
Else
//user pressed enter
End


very poorly written i think, but i dont have much time right now


Last edited by Guest on 18 Feb 2004 10:08:40 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 19 Feb 2004 09:14:02 am    Post subject:

Newbie wrote:
When you get the SE it gives you a manual about 20 pages long, and thats it. Sad

You can download a better one from TI's site.
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 19 Feb 2004 05:07:11 pm    Post subject:

Couldn't you do something to the effect of:

0->K
For(A,1,100
getkey->K
If K=105
100->A
End
If K
Then
(do stuff if enter is pressed)
Else
(do stuff if enter isn't pressed)
End

Yes, you do need to use K instead of just Ans, otherwise your keypress will always be 100. (100->A)

And if you want to respond to any keypress during that time, just change

If K=105 to If K><0 (not equal to)

If you have any questions, let me know!

Spyderbyte


Last edited by Guest on 19 Feb 2004 10:37:03 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 19 Feb 2004 05:08:50 pm    Post subject:

And the manual is on a CD that comes with the calc.

The key to learning how to program from the manual is reading all of the programming chapter, all of appendix A, and try to think about how each function could be used.
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 19 Feb 2004 05:10:06 pm    Post subject:

Yourm line with K does not equal zero what do you mean by that? What is zero suppose to be?
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 19 Feb 2004 05:14:44 pm    Post subject:

Sorry, I misread your original post, I thought you wanted to respond to any keypress. I changed it to just enter.

What is does is sets up a For( loop and checks for a keypress 100 times. If a key is pressed, it jumps to the end of the loop (100->A) and then you have the keypress stored into K.

Spyderbyte
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 19 Feb 2004 05:24:37 pm    Post subject:

Thanks thats what I wanted but the second end was not needed.
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 19 Feb 2004 10:35:14 pm    Post subject:

Oh oops sorry, originally I had an If K=105 Then 100->A End, but I took out the then to save a byte and forgot about the extra end. I'll go fix it.

Spyderbyte


Last edited by Guest on 19 Feb 2004 10:36:04 pm; edited 1 time in total
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 20 Feb 2004 01:52:58 am    Post subject:

first off, remove the 0->K at the begining. it isnt needed
second, use A(not(K))+100(K>0->A to check for keypresses. its bigger, but faster

so your code shoud be:

Code:
For(A,1,100
getKey->K
A(not(K))+100(K>0->A
End
If K //use If K=105 to check for enter key
Then
//a key was pressed
Else
//a key wasnt pressed
End
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 20 Feb 2004 10:29:34 pm    Post subject:

ClrHome
For(A,1,50
getKeyüK
A(not(K))+50(K>0üA
End
If K=105
Then
Goto 1
Else
Asm(prgmSHUTSRC
End
Lbl 1
Input "PASSCODE: ",A
If A=30213
ClrHome
Stop
If Aø30213
ClrHome
Asm(prgmSHUTSRC
Stop

Program Shutsrc shuts the calc down, but if you type in the wrong passcode it still just stops the program. Whats wrong?
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 21 Feb 2004 02:51:44 am    Post subject:

First of all, never put goto statements inside if:then:else:end branches, or inside loops. Why not? Well, the calc has to remember it's in a loop or if:then:else:end branch and if you then jump out of it with a goto it still remembers it's in a loop and this consumes memory. If you do it too much you'll get memory errors.

As for why it still quits the program, I'll exlpain what your program actually does after lbl 1...

Input "PASSCODE: ",A //store inputted password in A
If A=30213 //check if proper password is typed in
ClrHome //clear the screen if the proper password is typed in
Stop //stop program regardless of any previous if statements, because you forgot to either put this in a seperate lbl and goto there or use then:end
If Aø30213 //if wrong password
ClrHome //clear the screen
Asm(prgmSHUTSRC //run this program, also happends regardless of wether you typed the wrong password
Stop //stops the program, happends regardless of wether you typed the proper password

So all it does if you typed the proper password is clear the screen and continue from there, which means stop the program. If you'd have entered the wrong password it still comes to the stop part and ends the program.

I believe you'd want it to be like this:

ClrHome
Repeat Ans
getKey->K
50(K>0->A
End
If K=105
Goto 1
// no else is needed here because it'd go to lbl 1 if enter was pressed so it only ends up here if enter wasn't pressed
Asm(prgmSHUTSRC
Lbl 1
Input "PASSCODE: ",A
ClrHome //since it clears the screen in both cases I thought I'd just put it here once and save a bunch of bytes (since no then:end is needed now)
If A=30213
Stop
If Aø30213
Asm(prgmSHUTSRC
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 21 Feb 2004 11:00:37 am    Post subject:

If you dont press enter where would you stick to end the program so if you turned it on again it would not break.
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 21 Feb 2004 11:32:26 am    Post subject:

Not sure I understand what you're saying...?
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 21 Feb 2004 12:25:49 pm    Post subject:

What I mean is if you dont press enter it will turn the calc off, but wont stop the program so if you press on to turn it on it breaks. I want to know how to stop the execution of the program if you dont press enter so when you turn it on it wont break.
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 22 Feb 2004 05:13:11 am    Post subject:

'break' ????
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 22 Feb 2004 10:54:25 am    Post subject:

Newbie wrote:
What I mean is if you dont press enter it will turn the calc off, but wont stop the program so if you press on to turn it on it breaks. I want to know how to stop the execution of the program if you dont press enter so when you turn it on it wont break.

Confusing. So you want to do which?

1. Make the screen turned off while the program keeps going.

2. Disable the [on] key until enter is pressed.
Back to top
Newbie


Bandwidth Hog


Joined: 23 Jan 2004
Posts: 2247

Posted: 22 Feb 2004 01:50:08 pm    Post subject:

I want the program to stop if you dont press enter, but somehow after it turns itself off because I have a program that will turn the calc off.
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 22 Feb 2004 02:36:21 pm    Post subject:

Okay is this what you mean:
You want the program to stop executing as in the program will be "Done" if you don't press enter during the time limit, but what happens is that it automatically turns your whole calculator off after the time limit anyway

-OR-

You want the program to turn off your calculator and to stop executing WHILE the calculator is off.
Back to top
Display posts from previous:   
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement