Don't have an account? Register now to chat, post, use our tools, and much more.
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.

TI-Basic => TI-BASIC
 » Goto page Previous  1, 2
Author Message
Bhaliar

Member

Joined: 16 Nov 2009
Posts: 221

 Posted: 27 Feb 2010 05:23:23 pm    Post subject: That and the A, if your relating it to a graph is actually the y-axis. Remember that output isn't (X,Y) it's (Y,X) So if you had something like this: 4->A 8->B Output(A,B,"*" it would be:(zeroes are spaces) 0000000000000000 0000000000000000 0000000000000000 0000000*00000000 4th row, 8th column. 0000000000000000 0000000000000000 0000000000000000 0000000000000000
kinkoa

Member

Joined: 28 Jul 2009
Posts: 103

 Posted: 01 Mar 2010 09:26:17 am    Post subject: Finale TI wrote: shadowking wrote: Bhaliar wrote::8->A // :ClrHome // :Repeat K=105 // this wont work it needs to be K/=105; thats does not equal :Output(1,A," // :Repeat Ans // :getKey->K // :End // :Output(1,A,"* // .. :A+(Ans=26 and A<16)-(Ans=24 and A>2->A // :End The way it works is 1 is Stored to the variable A. The loop starts and The Character * is displayed on the first row, and the Ath column. Then, it takes a and if you pressed right and you have enough room, the * goes right. IF you press Left and have enough room, it goes left. it doesnt store 1 into A it stores A+1 or A-1 depending on which you pressed Actually, the loop condition is correct. If it was a While loop, you would be right, but a Repeat loop works with Repeat K=105. If you use Repeat K?105, then it will run through the loop once and end, not allowing movement, but only updating the screen with the *. well i almost never use repeat loops i wasnt sure how to work them that was mainly just a guess Bhaliar wrote:That and the A, if your relating it to a graph is actually the y-axis. Remember that output isn't (X,Y) it's (Y,X) So if you had something like this: 4->A 8->B Output(A,B,"*" it would be:(zeroes are spaces) 0000000000000000 0000000000000000 0000000000000000 0000000*00000000 4th row, 8th column. 0000000000000000 0000000000000000 0000000000000000 0000000000000000 thats also where the beginning of something starts for instance 0000000000000000 0000000000000000 0000000000000000 0000HI0WORLD0000 4th row, 5th column. 0000000000000000 0000000000000000 0000000000000000 0000000000000000Last edited by Guest on 01 Jul 2010 09:07:05 am; edited 1 time in total
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 01 Mar 2010 06:47:20 pm    Post subject: shadowking wrote:well i almost never use repeat loops i wasnt sure how to work them that was mainly just a guess I tend to think of Repeat loops as "Repeat until expression is true". Another interesting thing on Repeat loops: Repeat loops are the only loop (of the three) in TiBasic that are post-test. For example, run this code: :Repeat 1 :Disp "Loop Ran :End It will print "Loop Ran" to the screen, even though the repeat loop is always true. This is because Repeat is post-test. :) For example, the pre-test While loop would be: :While 0 :Disp "Loop Ran :End Neat, huh? :biggrin:
Bhaliar

Member

Joined: 16 Nov 2009
Posts: 221

 Posted: 01 Mar 2010 08:12:18 pm    Post subject: ztrumpet wrote: shadowking wrote:well i almost never use repeat loops i wasnt sure how to work them that was mainly just a guess I tend to think of Repeat loops as "Repeat until expression is true". Another interesting thing on Repeat loops: Repeat loops are the only loop (of the three) in TiBasic that are post-test. For example, run this code: :Repeat 1 :Disp "Loop Ran :End It will print "Loop Ran" to the screen, even though the repeat loop is always true. This is because Repeat is post-test. :) For example, the pre-test While loop would be: :While 0 :Disp "Loop Ran :End Neat, huh? :biggrin: I don't follow. Does repeat test itself after it does everything inside, while the while loop tests it first?
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 01 Mar 2010 09:27:51 pm    Post subject: Bhaliar wrote:Does repeat test itself after it does everything inside, while the while loop tests it first? That is correct.
Bhaliar

Member

Joined: 16 Nov 2009
Posts: 221

 Posted: 03 Mar 2010 03:17:57 pm    Post subject: ztrumpet wrote: Bhaliar wrote:Does repeat test itself after it does everything inside, while the while loop tests it first? That is correct. That is neat! Learn somethinjg new everyday.
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 04 Mar 2010 06:00:10 am    Post subject: If you want to learn two new things a day, I recommend reading the wiki. The first paragraph of the Repeat article could have given you this news earlier.Last edited by Guest on 04 Mar 2010 06:01:12 am; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

Bhaliar

Member

Joined: 16 Nov 2009
Posts: 221

 Posted: 04 Mar 2010 09:53:22 pm    Post subject: I do read wiki and have edited a page or two. I mainly to commands I have never heard of though. That and I have a patchy memory. In my head, not calc.XD
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 05 Mar 2010 03:43:02 pm    Post subject: Meishe91 wrote:Ok, back to the Output(1,A,"_ in the program. I'm not entirely sure what the point of this is to be honest haha (other than seeing where you are once the line is filled). At first I thought it was to cover up the trail, so unless I typed something in wrong that isn't what it does (though if you switch the Output( commands so the "*" is first instead of the space you will get the effect I just described where it erases the trail).Oops! The order should be Output the * first and then the space. I'm sorry about that. You did a really nice job explaining that! Great job! Last edited by Guest on 01 Jul 2010 09:08:23 am; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

 Posted: 05 Mar 2010 08:43:00 pm    Post subject: ztrumpet wrote: Meishe91 wrote:Ok, back to the Output(1,A,"_ in the program. I'm not entirely sure what the point of this is to be honest haha (other than seeing where you are once the line is filled). At first I thought it was to cover up the trail, so unless I typed something in wrong that isn't what it does (though if you switch the Output( commands so the "*" is first instead of the space you will get the effect I just described where it erases the trail).Oops! The order should be Output the * first and then the space. I'm sorry about that. You did a really nice job explaining that! Great job! So it really should be an erasing space? Like I gave the example. And thanks. Took me awhile haha.Last edited by Guest on 01 Jul 2010 09:14:21 am; edited 1 time in total
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 05 Mar 2010 10:31:15 pm    Post subject: Meishe91 wrote:So it really should be an erasing space? Like I gave the example. And thanks. Took me awhile haha. It was meant to make the * move around the top line of the screen. :) The code as it was meant to be: 8→A ClrHome Repeat K=105 Output(1,A,"* Repeat Ans getKey→K End Output(1,A,"_ //one space A+(Ans=26 and A<16)-(Ans=24 and A>1→A End If you think you've mastered understanding that one, try this: 8→A ClrHome Repeat Ans=105 A+(Ans=26)-(Ans=24 Ans-16((Ans=17)-not(Ans→A Output(1,Ans,"* Repeat Ans getKey End Output(1,A,"_ //one space End Good luck! Last edited by Guest on 01 Jul 2010 09:21:29 am; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

 Posted: 05 Mar 2010 11:01:32 pm    Post subject: ztrumpet wrote: Meishe91 wrote:So it really should be an erasing space? Like I gave the example. And thanks. Took me awhile haha. It was meant to make the * move around the top line of the screen. The code as it was meant to be: 8→A ClrHome Repeat K=105 Output(1,A,"* Repeat Ans getKey→K End Output(1,A,"_ //one space A+(Ans=26 and A<16)-(Ans=24 and A>1→A End If you think you've mastered understanding that one, try this: 8→A ClrHome Repeat Ans=105 A+(Ans=26)-(Ans=24 Ans-16((Ans=17)-not(Ans→A Output(1,Ans,"* Repeat Ans getKey End Output(1,A,"_ //one space End Good luck! Haha I'll explain it. But do you want the same amount of detail as last time or what? I'll leave that up to you haha. But just as a quick observation without testing it at all yet I'm pretty sure it achieves the same effect except it will wrap around the screen instead of being limited to 1-16 (when you go past 16 you start back at 1). Edit: I was right about what it does from my initial thought (for those of you who see this and didn't test it haha). I'll get an explaination up as soon as ztrumpet tells me if he wants detailed, medium, or basic haha.Last edited by Guest on 01 Jul 2010 09:28:30 am; edited 1 time in total
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 06 Mar 2010 10:31:55 am    Post subject: Explain it however you'd like. :) I'd probably say medium... Yes, the difference is it wraps around the screen here. Shiver: How's this RPG going? Last edited by Guest on 06 Mar 2010 10:32:24 am; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

 Posted: 06 Mar 2010 01:30:43 pm    Post subject: ztrumpet wrote:Explain it however you'd like. I'd probably say medium... Yes, the difference is it wraps around the screen here. Shiver: How's this RPG going? Haha dang, I hate indecision...but ok I'll go medium lol. Ya, I would like to know that as well. Edit: ztrumpet wrote: Meishe91 wrote:So it really should be an erasing space? Like I gave the example. And thanks. Took me awhile haha. It was meant to make the * move around the top line of the screen. The code as it was meant to be: 8→A ClrHome Repeat K=105 Output(1,A,"* Repeat Ans getKey→K End Output(1,A,"_ //one space A+(Ans=26 and A<16)-(Ans=24 and A>1→A End If you think you've mastered understanding that one, try this: 8→A ClrHome Repeat Ans=105 A+(Ans=26)-(Ans=24 Ans-16((Ans=17)-not(Ans→A Output(1,Ans,"* Repeat Ans getKey End Output(1,A,"_ //one space End Good luck! Ok, so here is the explanation for ztrumpet's new movement code that wraps around the screen. Enjoy :) Code: 8→A ClrHome Repeat Ans=105 A+(Ans=26)-(Ans=24 Ans-16((Ans=17)-not(Ans→A Output(1,Ans,"* Repeat Ans getKey End Output(1,A,"_ End Ok, well like last time i will go line by line, but probably not into nearly as much detail. Lets start: 8→A: Pretty simple. You're storing a value of 8 to the variable A. ClrHome: This clears the homescreen of everything that is currently on it. For more detail look at my last explanation. Repeat Ans=105: This is the beginning of the a Repeat loop that is waiting for you to hit [ENTER] (since it's key code is 105). A+(Ans=26)-(Ans=24: Little trickier. A currently has a value of 8 (when the program is run) so when you hit the left or right arrow key (which will be stored in Ans because getKey is the last line of the loop) you will either add 1, -1, or 0 to A. This answer will now be stored to Ans which sets up the next line. Ans-16((Ans=17)-not(Ans→A: Even more tricky. This is the line that lets the * wrap around. Like I had said the new value of A has been stored to Ans in the last line. You are essentially adding either 16, -16, or 0 and then storing it to A. How this works is that it takes the value in Ans and if this value is equal to either 17 or 0 you are multiplying 16 by 1 or -1 (thanks to the Boolean Logic I explained earlier with conditions). The reason this works with zero though is because of the not( command. This essentially reverses the Boolean Logic and returns the opossite (true becomes false and false becomes true). Now, to be honest this doesn't make the most ammount of sense to me but I do know why it is used here. Using the not( command in this way lets you replace the statement Ans=0 (because they return the same answer). It's used as an optimization right here. Output(1,Ans,"*: This outputs a * into row one, Ans number of columns out. You can use Ans here because of the last line. You are storing the value of A to Ans because it is a math operation basically. Hope that makes sense. Repeat Ans: This starts a loop that waits for you to push a button. It does this because the value from getKey gets stored to Ans. End: Ends the Repeat Ans loop. As specified earlier (in the previous explanation) End's specify the end of code inside loops (or a few other things that require them). Output(1,A,"_: This displays a space into row one and in column A. The reason for this Output( is to erase the * that would normally trail behind. End: This ends the Repeat Ans=105 loop. This completes the code so if you hit [ENTER] it will end the program (since nothing is beyond the End). So, quick recap: Code: 8→A //Stores a value of 8 to the variable "A." ClrHome //Clears the homescreen of anything that is on it. Repeat Ans=105 //Begins a loop that waits for [ENTER] to be pressed to end the program. A+(Ans=26)-(Ans=24 //Adds 1 or -1 to A depending if [◄] or [►] is pressed. "A" gets stored to "Ans." Ans-16((Ans=17)-not(Ans→A //This adds or subtracts 16 from "Ans" if "Ans" is equal to 17 or 0. Adds nothing if it doesn't equal either one. Stores the answer to "A." Output(1,Ans,"* //Displays a "*" in row one and "Ans" columns out. Repeat Ans //Starts a loop that waits for you to press a button. getKey //Stores the value of the key pressed to "Ans." End //Ends the "Repeat Ans" loop. Output(1,A,"_ //Displays a space in row one and in column "A." This erases the "*" left behind. End //Ends the "Repeat Ans=105" loop. I hope this has helped. Again, if you see any mistakes please let me know and I'll fix it.Last edited by Guest on 01 Jul 2010 09:27:40 am; edited 1 time in total
Weregoose
Authentic INTJ

Super Elite (Last Title)

Joined: 25 Nov 2004
Posts: 3976

 Posted: 06 Mar 2010 10:04:59 pm    Post subject: There's no better way to get something down pat than by teaching it to others. Last edited by Guest on 06 Mar 2010 10:05:11 pm; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

 Posted: 06 Mar 2010 10:13:15 pm    Post subject: Weregoose wrote:There's no better way to get something down pat than by teaching it to others. I agree Hence why I've been explaining those haha.
ztrumpet

Active Member

Joined: 06 May 2009
Posts: 555

 Posted: 07 Mar 2010 04:50:07 pm    Post subject: You did a great job on those explanations. :biggrin: I'm pretty sure you understand them too. Last edited by Guest on 07 Mar 2010 04:50:19 pm; edited 1 time in total
meishe91

Newbie

Joined: 06 Dec 2009
Posts: 49

 Posted: 07 Mar 2010 04:56:55 pm    Post subject: ztrumpet wrote:You did a great job on those explanations. :biggrin: I'm pretty sure you understand them too. Thank you They took quite a bit to write both of them. Really hope some people get use out of them.
 Display posts from previous: All Posts Oldest FirstNewest First
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.

»
 » Goto page Previous  1, 2 Page 2 of 2 » All times are GMT - 5 Hours