Calculator Community > TI-BASIC

TI-BASIC Q&A

<< < (3/17) > >>

Xeda112358:
Have you ever used Repeat loops? They are very lovely for these kinds of loops. Repeat will kepp repeating the loop until the condition is true. It does not test the condition before entering the loop (a while loop does). For example, this code will move a pixel around on the screen in a 16x16 area:

--- Code: ---3→X
3→Y
Repeat A=45     ;Later I will store the key value to A. This means repeat until clear is pressed.
pxl-Test(Y,X→C
9→B
Repeat A          ;getKey will be stored to A, so this repeats until a key is pressed
B+1
If Ans>9
Then
Pxl-Change(Y,X
0
End
Ans→B
getkey→A
End
If A=105     ;Enter
1→C
If A=23       ;Delete
0→C
If A=21       ;2nd
not(C→C
Pxl-Off(Y,X
If C
Pxl-On(Y,X
Y+(A=34)-(A=25
If Ans<0
15
If Ans>15
0
Ans→Y
X+(A=26)-(A=24
If Ans<0
15
If Ans>15
0
Ans→X
End

--- End code ---
I may have mistyped something, but that should give you an idea of how to make things work :)
You can press clear to exit, 2nd to invert the pixel, Enter to turn the pixel on, and Del to turn the pixel off.

EDIT: I love Repeat loops :) I actually learned them long before I understood While loops. It think this is more useful...

hellninjas:
Well then, Yay I just learned a new command!

Xeda112358:
Hehe, there are lots of cool things you can do in BASIC that you might never even think of O.O I just can't think of any at the moment...

hellninjas:
Its just to slow for me so thats why i use axe...

Xeda112358:
DJ_O used to make some pretty amazing/fast BASIC programs that could rival Axe >:D Although generally it is slower :/ People love the challenge of BASIC >:D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version