Libraries in TI-BASIC by Aeromax ~~Say you have a long part of code you want to reference from other programs. You might include this code in the program itself, but say you need it to be used by a ton of programs. Like a time-delay sequence for games that (by definition) is going to be long as hell. ~~Now here all you really have to do is create a program with a good reference name (one which won't have to be changed later) and reference that program within other ones. Here's an example of a delay sequence being referenced by external programs. PrgmFOOBAR Lbl BG Input "DELAY TIME: ",D randInt(1,2)->A If A=1 Disp "FOO" If A=2 Disp "BAR" Prgm DELAYSEQ ClrHome Disp "BAZBOP" ~~Let's go to the delay sequence program now. PrgmDELAYSEQ 0->X Repeat X=A X+1->X End ~~Now that's a good program, but can't be used in many programs. Why? Because it uses the common variable X. X gets used a lot, and its use in the delay sequence might overwrite another use of it (like the location of a cursor resetting to A every time you delay). Instead, let's use a list. There are infinite numbers of lists and it's highly unlikely that two would collide. PrgmDELAYSEQ 0->LDELAY(1) Repeat LDELAY(1)=A LDELAY(1)+1->LDELAY(1) End ~~Much better. But say we want to have it perform a function specific to this program. What to do? Well, we can put in a function switch. These are clunky, but they work well. PrgmFOOBAR Lbl BG Input "DELAY TIME: ",D randInt(1,2)->A If A=1 Disp "FOO" If A=2 Disp "BAR" 1->LDELAY(2) Prgm DELAYSEQ ClrHome Disp "BAZBOP" PrgmDELAYSEQ 2-> dim(LDELAY) ~~(this is necessary so it doesn't give a dimension error with the second element) 0->LDELAY(1) Repeat LDELAY(1)=A LDELAY(1)+1->LDELAY(1) If LDELAY(2)=1 Then Disp "HAM" End End You can use control switches like this in a lot of places, not the least of all are subroutines in programs.