Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: parserp on November 18, 2011, 05:05:05 pm

Title: TI-BASIC Q&A
Post 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?  :)
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 18, 2011, 05:26:32 pm
Yeah, is there anyway to end an if statement like just using end in Axe?
Title: Re: TI-BASIC Q&A
Post by: FinaleTI on November 18, 2011, 05:28:20 pm
Yeah, is there anyway to end an if statement like just using end in Axe?
Yes. You'll need to use If:Then.
Code: [Select]
If ...condition...
Then
...do stuff...
End
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 18, 2011, 05:50:11 pm
Ok. That was easy. How the heck didn't I know that?!
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 08:37:46 pm
Also, if you only have one line following the If statement, you don't need an End or a Then :)
For example:
Code: [Select]
If A=1
3→D
Title: Re: TI-BASIC Q&A
Post by: hellninjas on November 19, 2011, 08:43:51 pm
Is there an easier way to use the GetKey function?
Im kinda tired of WHILE 0...
Title: Re: TI-BASIC Q&A
Post by: parserp on November 19, 2011, 08:44:37 pm
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... ???
Title: Re: TI-BASIC Q&A
Post by: hellninjas on November 19, 2011, 08:46:15 pm
While 0 being the infinite loop statement...
While 0
getkey->A
While A=(KEY PRESS)
getkey->A
End
Im tired of the above implement...
Title: Re: TI-BASIC Q&A
Post by: parserp on November 19, 2011, 08:48:00 pm
it is possible to just do this:
Code: [Select]
:While 1
:If getKey=(key press)
:do something
:If getKey=(another press)
:do something else
:End
Title: Re: TI-BASIC Q&A
Post by: hellninjas on November 19, 2011, 08:49:17 pm
Hmm, thanks!
This will help my ZOMBASIC game!
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:03:36 pm
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: [Select]
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...
Title: Re: TI-BASIC Q&A
Post by: hellninjas on November 19, 2011, 09:06:13 pm
Well then, Yay I just learned a new command!
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:10:11 pm
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...
Title: Re: TI-BASIC Q&A
Post by: hellninjas on November 19, 2011, 09:10:52 pm
Its just to slow for me so thats why i use axe...
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:13:11 pm
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
Title: Re: TI-BASIC Q&A
Post by: FinaleTI on November 19, 2011, 09:32:13 pm
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*
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:44:39 pm
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 :)
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 19, 2011, 09:52:37 pm
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....
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:53:19 pm
What assembly programs or apps did you run?
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 19, 2011, 09:55:15 pm
DCS7?
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 09:56:16 pm
If that was all you had, that was probably what corrupted it :/
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 19, 2011, 09:57:54 pm
Doors and axe are my only programs. If this is another doors, I'm switching to another shell. 
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 10:01:26 pm
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 :)
Title: Re: TI-BASIC Q&A
Post by: FinaleTI on November 19, 2011, 10:01:47 pm
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.
Title: Re: TI-BASIC Q&A
Post by: epic7 on November 19, 2011, 10:02:32 pm
It's a very simple game. Just move a plus sign around and collect pies. (3.14 pies)
Title: Re: TI-BASIC Q&A
Post by: Xeda112358 on November 19, 2011, 10:04:10 pm
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
Title: Re: TI-BASIC Q&A
Post by: epic7 on December 08, 2011, 07:24:58 pm
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
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on December 08, 2011, 07:37:48 pm
Maybe your screen dimensions were changed? Check the values under WINDOW and see if the Line() commands fall within the screen.
Title: Re: TI-BASIC Q&A
Post by: parserp on December 08, 2011, 07:54:57 pm
Parser, I envy you since you have recieved the honor of having a topic stickied. :P
:D
Title: Re: TI-BASIC Q&A
Post by: epic7 on December 08, 2011, 08:13:30 pm
Ok, screen dimentions were wrong/me adds zstandard
That will work, right?
Title: Re: TI-BASIC Q&A
Post by: parserp on December 08, 2011, 08:14:33 pm
Ok, screen dimentions were wrong/me adds zstandard
That will work, right?
yes, if you want a 10*10 window. ;)
Title: Re: TI-BASIC Q&A
Post by: epic7 on December 08, 2011, 08:15:30 pm
I just wan't to keep that game and have it work for historical reasons :P
Title: Re: TI-BASIC Q&A
Post by: njaddison on December 08, 2011, 08:46:42 pm
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?
Title: Re: TI-BASIC Q&A
Post by: epic7 on December 08, 2011, 08:47:10 pm
83 and 84 basic
Title: Re: TI-BASIC Q&A
Post by: parserp on December 08, 2011, 08:47:23 pm
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:
Title: Re: TI-BASIC Q&A
Post by: epic7 on December 08, 2011, 08:47:51 pm
Ninja'd :ninja:

I think there's an nspire basic somewhere though.
Title: Re: TI-BASIC Q&A
Post by: CVSoft on January 02, 2012, 11:54:25 pm
I'm reworking my Windows 85/86 program, and would like to know if there is any way to shrink this code:

Code: [Select]
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.
Title: Re: TI-BASIC Q&A
Post by: parserp on January 02, 2012, 11:55:48 pm
Code: [Select]
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
Title: Re: TI-BASIC Q&A
Post by: Builderboy on January 02, 2012, 11:57:01 pm
I'm reworking my Windows 85/86 program, and would like to know if there is any way to shrink this code:
Try this
Code: [Select]
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.
Title: Re: TI-BASIC Q&A
Post by: CVSoft on January 03, 2012, 06:43:35 pm
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!
Title: Re: TI-BASIC Q&A
Post by: parserp on February 06, 2012, 04:09:33 pm
I never learned what 'Tangent' and 'sub' do in BASIC. Could someone enlighten me?
Title: Re: TI-BASIC Q&A
Post by: Builderboy on February 06, 2012, 04:15:08 pm
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
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on February 06, 2012, 04:39:12 pm
[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 :)).
Title: Re: TI-BASIC Q&A
Post by: nxtboy III on March 01, 2012, 09:12:36 pm
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?
Title: Re: TI-BASIC Q&A
Post by: Yeong on March 01, 2012, 09:13:24 pm
instead of array, we have list (element start from 1, not 0 >:D).
for key check, we use getKey.
Title: Re: TI-BASIC Q&A
Post by: nxtboy III on March 01, 2012, 09:14:59 pm
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?
Title: Re: TI-BASIC Q&A
Post by: Builderboy on March 01, 2012, 09:17:59 pm
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.
Title: Re: TI-BASIC Q&A
Post by: parserp on March 01, 2012, 09:18:41 pm
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
Title: Re: TI-BASIC Q&A
Post by: chattahippie on March 01, 2012, 09:19:29 pm
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:
Code: [Select]
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]
Title: Re: TI-BASIC Q&A
Post by: nxtboy III on March 01, 2012, 09:23:55 pm
Cool, thanks! So the list has 5 values max?
Title: Re: TI-BASIC Q&A
Post by: parserp on March 01, 2012, 09:26:18 pm
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?
Title: Re: TI-BASIC Q&A
Post by: Yeong on March 01, 2012, 09:27:12 pm
Lists have 999 elements max.
Title: Re: TI-BASIC Q&A
Post by: nxtboy III on March 01, 2012, 09:30:30 pm
yes, it does. :)
What key do I press to get dim(?
Is it in PRGM?

EDIT: its in LIST
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on March 01, 2012, 09:30:42 pm
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:
Quote from: TI-BASIC
{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.)
Title: Re: TI-BASIC Q&A
Post by: parserp on March 01, 2012, 09:31:17 pm
yes, it does. :)
What key do I press to get dim(?
Is it in PRGM?
Press "2ND", "STAT", right arrow, and "3". ;)
Title: Re: TI-BASIC Q&A
Post by: nxtboy III on March 01, 2012, 09:35:13 pm
Thanks for the help, guys/girls. :)
Title: Re: TI-BASIC Q&A
Post by: TI-Over9000 on March 02, 2012, 12:24:37 pm
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?
Title: Re: TI-BASIC Q&A
Post by: Builderboy on March 02, 2012, 12:28:04 pm
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.   
Title: Re: TI-BASIC Q&A
Post by: TI-Over9000 on March 02, 2012, 12:31:09 pm
Thank you I appreciate it.
TI has made alot of stupid mistakes, but i still <3 them.
Title: Re: TI-BASIC Q&A
Post by: chattahippie on March 04, 2012, 09:47:05 pm
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
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on March 04, 2012, 10:02:34 pm
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...
Title: Re: TI-BASIC Q&A
Post by: chattahippie on March 10, 2012, 02:07:15 pm
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
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on March 10, 2012, 07:17:44 pm
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
Quote from: TI-BASIC
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.
Title: Re: TI-BASIC Q&A
Post by: chattahippie on March 10, 2012, 07:53:21 pm
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
Quote from: TI-BASIC
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.
Thanks!  The nDeriv trick seems handy (reduces the amount of lines drawn :P )!
Title: Re: TI-BASIC Q&A
Post by: tpt1234567890 on October 28, 2013, 11:39:01 pm
Can anyone tell me how to use the StartTMR function pls?
Title: Re: TI-BASIC Q&A
Post by: Sorunome on October 29, 2013, 05:52:37 am
You do it like this:
Code: [Select]
:startTmr -> A
:Pause  //just to let time pass
:checkTmr(A)    //returns the seconds passed since you started the timer
Title: Re: TI-BASIC Q&A
Post by: Streetwalrus on October 29, 2013, 11:32:54 am
You can also do startTmr-A which does the same as checkTmr(A). Prolly less optimal though. ;)
Title: Re: TI-BASIC Q&A
Post by: tpt1234567890 on October 29, 2013, 05:11:52 pm
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.)
Title: Re: TI-BASIC Q&A
Post by: Deep Toaster on October 29, 2013, 08:43:19 pm
TI-BASIC only allows single-letter variable names, but list names can be up to five characters long.
Title: Re: TI-BASIC Q&A
Post by: TheCoder1998 on October 30, 2013, 04:31:40 pm
hey i recommend not to program in TI-BASIC and to program in axe
it's much more convenient
and faster too
Title: Re: TI-BASIC Q&A
Post by: Hayleia on October 31, 2013, 03:43:30 am
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).
Title: Re: TI-BASIC Q&A
Post by: TheCoder1998 on October 31, 2013, 04:19:43 am
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
Title: Re: Re: Re: TI-BASIC Q&A
Post by: DJ Omnimaga on October 31, 2013, 05:24:29 pm
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.
Title: Re: TI-BASIC Q&A
Post by: blue_bear_94 on October 31, 2013, 09:15:51 pm
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.
Title: Re: TI-BASIC Q&A
Post by: TheCoder1998 on November 01, 2013, 02:04:52 am
Quote
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
Title: Re: TI-BASIC Q&A
Post by: tpt1234567890 on November 01, 2013, 04:44:04 pm
Also, is it possible to restart the StartTmr? If so, How?
Title: Re: TI-BASIC Q&A
Post by: blue_bear_94 on November 01, 2013, 05:18:01 pm
Call it again.
Title: Re: TI-BASIC Q&A
Post by: tpt1234567890 on November 01, 2013, 05:35:38 pm
Call it again.
oh. OK. Just checking, but it goes up by 1 every second?
Title: Re: TI-BASIC Q&A
Post by: Streetwalrus on November 01, 2013, 06:24:38 pm
Yeah.
Title: Re: TI-BASIC Q&A
Post by: Thomas the Death Machine on October 28, 2014, 02:07:41 pm
is there a way to store variable inside a code or modify the code itself using ONLY ti basic?
Title: Re: TI-BASIC Q&A
Post by: Happybobjr on October 28, 2014, 03:19:14 pm
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)
Title: Re: TI-BASIC Q&A
Post by: ben_g on October 28, 2014, 03:35:19 pm
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.
Title: Re: TI-BASIC Q&A
Post by: Thomas the Death Machine on October 28, 2014, 04:13:54 pm
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