Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: parserp on November 18, 2011, 05:05:05 pm
-
Seeing as how we have an Axe Q&A (http://ourl.ca/9165), I thought it would be nice to have a TI-BASIC Q&A.
Although this probably won't be used as much as the Axe one, I thought it would be a good Idea to have a thread where you can ask questions about TI-BASIC! ;D
...So, anyone want to start us off with our Q&A? :)
-
Yeah, is there anyway to end an if statement like just using end in Axe?
-
Yeah, is there anyway to end an if statement like just using end in Axe?
Yes. You'll need to use If:Then.
If ...condition...
Then
...do stuff...
End
-
Ok. That was easy. How the heck didn't I know that?!
-
Also, if you only have one line following the If statement, you don't need an End or a Then :)
For example:
If A=1
3→D
-
Is there an easier way to use the GetKey function?
Im kinda tired of WHILE 0...
-
Is there an easier way to use the GetKey function?
Im kinda tired of WHILE 0...
? could you post some code? I'm not understanding your question... ???
-
While 0 being the infinite loop statement...
While 0
getkey->A
While A=(KEY PRESS)
getkey->A
End
Im tired of the above implement...
-
it is possible to just do this:
:While 1
:If getKey=(key press)
:do something
:If getKey=(another press)
:do something else
:End
-
Hmm, thanks!
This will help my ZOMBASIC game!
-
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:
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
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...
-
Well then, Yay I just learned a new command!
-
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...
-
Its just to slow for me so thats why i use axe...
-
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
-
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...
Scrolling tilemappers that use Pics for map data (http://ourl.ca/8608/160272), anyone?
*walks away whistling*
-
Now I want to see what I can do O.O I remember I used to store strings to pictures by storing 19 letters to a row (I used 5 pixels to determine which of 32 chars to use and vice versa). So I would get 1197 characters out of 767 bytes instead of 1208 bytes :)
-
Can anyone think of why my first game ever made with basic has totaly had its code messed up? I deleted it cuz it was so simple but it was totally screwed up.
Maybe that's another doors related problem....
-
What assembly programs or apps did you run?
-
DCS7?
-
If that was all you had, that was probably what corrupted it :/
-
Doors and axe are my only programs. If this is another doors, I'm switching to another shell.
-
In any event, it is very likely not the fault of the OS or the program XD That is the best part about BASIC-- you usually have to know some really advanced stuff to make it cause a glitch or a crash :)
-
Now I want to see what I can do O.O I remember I used to store strings to pictures by storing 19 letters to a row (I used 5 pixels to determine which of 32 chars to use and vice versa). So I would get 1197 characters out of 767 bytes instead of 1208 bytes :)
Nice. At one point, I was playing with the idea of doing an RPG in BASIC that would use Pics for all long term data storage. I even had an inventory system based off Illusiat 13's, and a rudimentary sorting system for it. But that's all long gone, unfortunately.
-
It's a very simple game. Just move a plus sign around and collect pies. (3.14 pies)
-
I did that! In one of my first RPG's I stored EVERYTHING to a picture for save data. I even let the user make custom sprites for their character (they could only view it in the stats menu). I felt so clever when I realised I could use the pixels as powers of 2, then I learned that was called binary XD
EDIT: @epic7: That probably didn't cause a crash then XD
-
Idk... Well my opening title screen doesn't work
For(x,-10,5,1.5
Line(-10,-10,10,X
Line(10,-10,-10,X
End
That used to work, but not anymore D:
Unless I changed it.. Idk since I forgot how most of the draw commands work in basic now :P
Parser, I envy you since you have recieved the honor of having a topic stickied. :P
-
Maybe your screen dimensions were changed? Check the values under WINDOW and see if the Line() commands fall within the screen.
-
Parser, I envy you since you have recieved the honor of having a topic stickied. :P
:D
-
Ok, screen dimentions were wrong/me adds zstandard
That will work, right?
-
Ok, screen dimentions were wrong/me adds zstandard
That will work, right?
yes, if you want a 10*10 window. ;)
-
I just wan't to keep that game and have it work for historical reasons :P
-
What kind of Ti-Basic are you guys talking about? nspire basic, which I know alot about, or ti-84 basic, which I know almost nothing about?
-
83 and 84 basic
-
What kind of Ti-Basic are you guys talking about? nspire basic, which I know alot about, or ti-84 basic, which I know almost nothing about?
yes, the latter. (83 BASIC) :)
EDIT: ninja'd! and lost the game! :ninja:
-
Ninja'd :ninja:
I think there's an nspire basic somewhere though.
-
I'm reworking my Windows 85/86 program, and would like to know if there is any way to shrink this code:
0→x
Repeat x
getKey→x
End
If x≠[a getKey value]
Goto [label]
Is it possible? How would this be done?
It was originally TI-85 code, but it works (and preferably needs to work) from TI-82 to TI-86.
-
Repeat GetKey
End
If Ans≠[a getKey value]
Goto [label]
that should work...
Also Parser that code would not work at all, or at least not do the same thing. It only checks for a key once, and if there is no key, the loop will go forever.
ah yes, fixed ;D (I think) :P
-
I'm reworking my Windows 85/86 program, and would like to know if there is any way to shrink this code:
Try this
Repeat Ans
getKey
End
If Ans≠[a getKey value]
Goto [label]
Also Parser that code would not work at all, or at least not do the same thing. It only checks for a key once, and if there is no key, the loop will go forever.
-
I've forgotten to say that the returned key may need to be stored (many complicated reasons [simulated keypresses over link on 83+]) but that's an easy fix.
Parser: This code only seems to work on the 83 series; it returns 0 for Ans on the 85 series. It is about as small as it gets without starting any contests.
Builderboy: That code works well for the 85/86; I realized the 0→x part was unnecessary as Repeat doesn't test before running.
Thank you both for your help!
-
I never learned what 'Tangent' and 'sub' do in BASIC. Could someone enlighten me?
-
You should check out TiBasic Developer (http://tibasicdev.wikidot.com/forum:home), they have well documented pages on pretty much every TiBasic command there is! Just type whatever command you are curious about into the search bar and learn :D
-
[tibd]sub[/tibd] returns a substring and is one of the most useful commands there is. [tibd]Tangent[/tibd] draws a tangent to a curve. As Builderboy suggested, look on TI|BD for usage info (links right in this post :)).
-
I'm a real super super super beginner, but how do you check if a certain key is pressed?
Also are there arrays in BASIC?
-
instead of array, we have list (element start from 1, not 0 >:D).
for key check, we use getKey.
-
Could you give an example using a list?
Also could you be more specific on how I can check if a certain key is pressed? maybe an example?
-
We can't check whether or not a certain key is being pressed, but the command getKey returns the number corresponding to the most recently pressed key.
-
To use getKey, here are the keycodes:
(http://images.wikia.com/tibasic/images/e/e1/Getkey.PNG)
to use them, it would be like this:
to see if "2ND" is pressed:
If getKey=21 : do stuff
or you could store the key into something:
getKey->C
If C=21
do stuff
-
The lists are formated like {1,2,3,4,5} and you can use custom lists by using the little L (under the List menu.)
As for getKey, to find out which key is which, make something like this:
Repeat G=22
getKey->G
If G=/=0
Disp G
End
This will return the numeric value of any key, and will end when you press [MODE]
-
Cool, thanks! So the list has 5 values max?
-
no, lists can be as big or as small as you want them to be. (max=999 numbers) I would suggest creating a new list:
:18->dim(LDATA)
:1->LDATA(1)
as you can see, this creates list DATA with 18 numbers in it (they are all 0's), and it stores 1 into the first number of LDATA.
If you don't do the dim( part, it will give you an ERR:UNDEFINED. dim( stands for dimension. so you are creating LDATA with a dimension of 18. (18 numbers)
Does that make sense?
-
Lists have 999 elements max.
-
yes, it does. :)
What key do I press to get dim(?
Is it in PRGM?
EDIT: its in LIST
-
Lists can be any realistic length ("realistic" as in anything that fits in RAM). dim(LIST) returns the dimensions/size/length of the list, whatever you want to call it, and you can also set the list's length with NUMBER→dim(LIST). dim( can be found under 2nd+[list]>OPS.
Alternatively, you can set the value of the nth element in list LIST with LIST(n) as long as n is between 1 and the length of the list, plus one. For example:{0}→L1
1→L1(1)
2→L1(2)
L1 is now {1,2}.
(If you're wondering, L1 through L6 are the default lists that you can access via 2nd followed by a number key from 1 to 6. For named lists, it's LNAME where NAME can be one to five numbers, letters, or thetas, starting with a letter or theta.)
-
yes, it does. :)
What key do I press to get dim(?
Is it in PRGM?
Press "2ND", "STAT", right arrow, and "3". ;)
-
Thanks for the help, guys/girls. :)
-
When I do linreg r and r^2 are not displayed on my calc but they are on my friends calc. Can anyone help me please?
-
Find the DiagnosticsOn token in your catalog and run that on the homescreen. This will turn on diagnostics and display r and r^2. Why TI decided they would be off by default, and why they decided against putting the option in the MODE menu is beyond me.
-
Thank you I appreciate it.
TI has made alot of stupid mistakes, but i still <3 them.
-
Find the DiagnosticsOn token in your catalog and run that on the homescreen. This will turn on diagnostics and display r and r^2. Why TI decided they would be off by default, and why they decided against putting the option in the MODE menu is beyond me.
In 2.55MP it is under Stat Diagnostics in the MODE menu
-
And just a tip (because I often see my friends in Stats doing a lot more work than they need to): it's really a mode setting (and TI finally put it in the MODE menu in the MP OSes, as chattahippie said), so if you don't have an MP OS and you're finding the DiagnosticOn token in the catalog (like Builderboy said), you only need to do so once and the r-values will stick around unless you clear your RAM.
And like Builderboy, I have absolutely no idea why TI doesn't just show them by default—they're so commonly used and don't take very long to calculate (at least from what I've seen), and when you're using LinReg they just fill two rows on the screen that would have been empty anyway, so there's no disadvantage there...
-
When I use the Tangent command (2nd, Draw, 5), is there any way to store the equation it generates to a Y= variable?
Also, is there an easy way to find the angle between two lines that intersect?
EDIT: I was searching around, and it seems that Tangent changes the values in X and Y, so I can do the first question by using algebra
-
You could also use nDeriv( to find slope of the tangent line. The syntax is nDeriv(<expression>,<real>,<number>), where <expression> is the original curve (which you used for Tangent(), <real> is the independent variable (here X), and <number> is the X-value of the tangent. So if you wanted to find the tangent equation of Y=X2 at X=3, the slope would be
nDeriv(X2,X,3)
For your second question, here (http://mathcentral.uregina.ca/QQ/database/QQ.09.99/patterson2.html) is a nice guide. Basically, since you know the slopes, you can find the tangents of the two angles, and since you can find the tangents of the two angles, you can find the actual angle difference.
-
You could also use nDeriv( to find slope of the tangent line. The syntax is nDeriv(<expression>,<real>,<number>), where <expression> is the original curve (which you used for Tangent(), <real> is the independent variable (here X), and <number> is the X-value of the tangent. So if you wanted to find the tangent equation of Y=X2 at X=3, the slope would benDeriv(X2,X,3)
For your second question, here (http://mathcentral.uregina.ca/QQ/database/QQ.09.99/patterson2.html) is a nice guide. Basically, since you know the slopes, you can find the tangents of the two angles, and since you can find the tangents of the two angles, you can find the actual angle difference.
Thanks! The nDeriv trick seems handy (reduces the amount of lines drawn :P )!
-
Can anyone tell me how to use the StartTMR function pls?
-
You do it like this:
:startTmr -> A
:Pause //just to let time pass
:checkTmr(A) //returns the seconds passed since you started the timer
-
You can also do startTmr-A which does the same as checkTmr(A). Prolly less optimal though. ;)
-
Thanks guys! (P.S. Im trying to get this program to "update" (add cookies in cookie clicker) every second. Trying this in BASIC just for the heck of it right now... Anyone know how to do that? Also, is it possible to save numbers into variable names that we set (like CK, COOKIE, C1, etc.) or does it have to be a single-letter variable? If this is unclear its the A in Prompt A, input A, etc.)
-
TI-BASIC only allows single-letter variable names, but list names can be up to five characters long.
-
hey i recommend not to program in TI-BASIC and to program in axe
it's much more convenient
and faster too
-
hey i recommend not to program in TI-BASIC and to program in axe
it's much more convenient
and faster too
I code in Axe but I don't agree with your argumentation because in the same lines, one could say "hey I recommend not to program on a calculator and to program on a PC. It's much more convenient and faster too".
But what about people who like challenges ? Coding awesome things on a limited platform ? Coding awesome things on a limited platform in its most limited language ?
And what about people who have friends who don't know at all how to run ASM programs so they "have to" program in Basic if they want their friends to play their games (and don't tell me "introduce them a shell" because I tried and they told me a month later "how do I quit MirageOS ? I never used it in a month and I don't remember". And don't tell me "introduce them DoorsCS" because they had regular 83+ calculators. And don't even speak about zStart, they don't know what a RAM Clear is) ?
(Also, Axe is not always "much more convenient". Try to make an advanced maths program. I don't say you wouldn't manage, just that you would have got the same result in half no time in Basic).
-
okay you're right
i think i had my trollface still on when i posted that :P
anyway i agree that basic is much better if you want to program math programs, and axe is better for games
-
hey i recommend not to program in TI-BASIC and to program in axe
it's much more convenient
and faster too
Although Axe makes graphics and animations much easier to display, it's much harder for other things, though. It took me hours just to implement switching between levels in Super Sonic Ball and about a day to make a Tunnel game (something I did in a few hours in xLIB 84C despite not being designed for side scrolling games). Besides, it's against Omnimaga rules to discourage people from using a language or another, especially in an help topic about a specific language.
-
Does anyone else have problems with DelVars before While or Repeat loops, with no newline or colon in between? I sometimes get that bug on my 84PSE with 2.43.
-
it's against Omnimaga rules to discourage people from using a language or another, especially in an help topic about a specific language.
i'm sorry. i won't ever do that again. EVER. I PROMISE.
but yeah axe can also be difficult to code sometimes, i agree
-
Also, is it possible to restart the StartTmr? If so, How?
-
Call it again.
-
Call it again.
oh. OK. Just checking, but it goes up by 1 every second?
-
Yeah.
-
is there a way to store variable inside a code or modify the code itself using ONLY ti basic?
-
Sorry if I misinterpreted your question:
TI-Basic does not really support self-modifying code (smc). However using graphing variables, there is a rudementary way of doing it as seen in the link below:
http://tibasicdev.wikidot.com/selfmodify (http://tibasicdev.wikidot.com/selfmodify)
-
is there a way to store variable inside a code or modify the code itself using ONLY ti basic?
If you only want to store variables between runs of the program, I'd suggest you look into lists. You can create lists with custom names, and they can hold a lot of information (999 numbers to be exact)
If you do 55->dim(LLIST), then you create a list named LIST that can hold 55 numbers. If the list already exists, it will be cropped to the correct size with zeros being added for elements that didn't exist previously (this also means that executing this code when the list already exists doesn't modify the list). A newly created list will be automatically filled with zeros.
An alternate way of creating a list is like this:
{0,1,2,3,4,5,6,7,8,9}->LLIST, which will store all those elements into a new list of the correct size. If the list already existed, it will be completely overwritten.
Every one of those can be used as a variable like this:
LLIST(5) will return the value of the variable, kinda like simply using A. You can also modify variables like this: 8->LLIST(5)
It even works when you use a variable inside the brackets: LLIST(A) will return the Ath element in the list.
-
is there a way to store variable inside a code or modify the code itself using ONLY ti basic?
If you only want to store variables between runs of the program, I'd suggest you look into lists. You can create lists with custom names, and they can hold a lot of information (999 numbers to be exact)
If you do 55->dim(LLIST), then you create a list named LIST that can hold 55 numbers. If the list already exists, it will be cropped to the correct size with zeros being added for elements that didn't exist previously (this also means that executing this code when the list already exists doesn't modify the list). A newly created list will be automatically filled with zeros.
An alternate way of creating a list is like this:
{0,1,2,3,4,5,6,7,8,9}->LLIST, which will store all those elements into a new list of the correct size. If the list already existed, it will be completely overwritten.
Every one of those can be used as a variable like this:
LLIST(5) will return the value of the variable, kinda like simply using A. You can also modify variables like this: 8->LLIST(5)
It even works when you use a variable inside the brackets: LLIST(A) will return the Ath element in the list.
Thanks! I was going to use this to make a game that could store a "cash" variable that couldn't easily be erased
-
What does BASIC stand for? Beginners something?
-
What does BASIC stand for? Beginners something?
Hello! Welcome to the Forum! BASIC stands for "Beginners' All-purpose Symbolic Instruction Code".
https://en.wikipedia.org/wiki/BASIC
Best of luck in your BASIC adventures!