Ti-BASIC

The Ti-BASIC is the computer programming language graphic Calculatrices Texas Instruments. It resembles the language BASIC, from where its name. The Ti-BASIC included in the computers based on Motorola 68000 (“68 K”) is not the same one as that of the computers based on Z80. Each model of computer has exploitable particular functionalities by the programs, but the heart of the language is common.

Brief description of the language

Types of data

The variables usable are those accessible since the screens from calculation. For example, in the case of TI-82:
  • numbers with Floating decimal point (variable indicated by the letters of the alphabet);
  • matrices;
  • lists (statistical);
  • functions of graphs;
  • the variables system;
  • tables of figures.

TI-82 does not allow the storage and the handling of other types of data, like the character strings. It is only possible to post chains. It is about a language with strong Typage, by considering that it is not possible to modify or to choose the type of values of the variables. The variables do not need to be declared before being used in an expression. All the variables are total.

Other types of data (for example, character strings) are available on other models.

Syntax

Syntax very simple and is adapted to any beginner in programming. These machines constitute following the example BASIC an excellent means of being initiated with the programming and of discovering mathematics more in a “ludic” way that a lecture.

Other sides of the coin, the possibilities rather reduced and are concentrated only on the relatively simple mathematical algorithms. Some succeeded in programming more complex programs, for example plays, but it is almost imperative in this case to have recourse to the Assembleur.

On the computers containing Z80, to seize the instructions in the program, they should not be typed with the alphanumeric keyboard, considering the letters represent variables. They must be selected each time in the menu Prgm. Thus, to finish an expression, it is the character double-point which is used, this one being automatically added to each beginning of new line. It is also available manually to seize several instructions on the same line.

The orders of control and loop must be finished using the keyword End, which is used as marker of end of block (in the same way that the accodance in the languages of the family of the C).

The errors of syntax or overflow are announced same manner as for any other expression seized on the machine, and cause the program stop with an error message.

Controls

The Ti-BASIC supports the fundamental concepts of control, namely:
  • the Assignment with the arrow directed on the right (→): the expression located on the left of the arrow is evaluated, and the result is arranged in the variable located on the right;
  • conditional branch instructions If, Then, Else, EndIf;
  • the loops: While (Z80), Repeat (Z80) or Loop (68K), For;
  • connections, with the instruction Goto and labels indicated by Lbl. Moreover, one order Menu (Z80) or ToolBar (68K) makes it possible to post a menu of options, each one carrying out a connection towards a specified label.

Inputs/outputs

The instructions of inputs/outputs are:
  • Input and Prompt, in order to ask the user to type a value to be assigned to a variable;
  • Output, in order to post a variable or a chain on a site of the screen, contrary with the following one;
  • Disp, which only makes it possible to leave a variable in flow the principal screen;
  • DispGraph, DispTable, which posts the graph or the current table;
  • ClrHome, ClrTable, which erases the principal screen or the current table;
  • PrintScreen (z80), prints the screen running on an external peripheral if connected;
  • Get and Send to which GetCalc and SendCalc are added on 68K and SendChat for news 68K; they export or import a variable since an external device (another machine);
  • getKey finally makes it possible to obtain the code ( Scancode ) corresponding to the last key in a hurry.

Creation of functions and programs

In the computers based on Motorola 68000, a function or a program can be created directly by using the function Define, its syntax is:

Define ma_fonction (v1. , vN) = Func: function…: EndFunc

This can be used inside an other function and thus implements local functions and programs.

In the computers based on Z80, this is impossible. The only possibility is to call other programs recorded on the machine, by supposing that they are quite present, and those do not support arguments.

Others

In the instructions the many mathematical functions of the various machines are of course available.

It is possible to exchange programs by connecting two computers per cable, or by connecting the computer to a computer; this also allowing to have recourse to an emulator on computer in order to facilitate striking and the development of a program.

Sample programs

Hello world

The keyword Disp makes it possible to post traditional the Hello world with the screen:

Disp "HELLO, WORLD! "

But one can also use another function, which will post hello world with the coordinates defined by X and Y:

Output (Y, X, " HELLO WORLD")

Square of a number

To make a program which posts the square of a number, it is necessary:
  • to enter the number, with the instruction Input which admit in first argument the message of invites and as a second the name of the variable which will receive the number:
Input " With =" ,
has
  • to calculate the square, thanks to the key ² and to assign this result with a variable (optional) with the key :
has ² →R
  • to post the number, with the instruction Disp which posts an argument by line:
Disp "With ² =" , R

The instructions Input and Disp are in the sub-menu I/O while supporting on PRGM during the edition of the program.

To find the dividers of a number (in ℕ)

This program makes it possible to find the dividers of a number. It shows several essential structures of the programming Ti-BASIC. It stores these dividers in a list L 1 qu ' it posts at the end of the execution.

: 0→P Initialization of the variable : Input " N=" , NR Requires the number which one wants to find the dividers : ClrList L1 Suppresion of the L1 list (so existing) : For (I, 1, NR) Beginning of the loop For : For I varying of 1 to NR : N/I→A Divides the selected number at the beginning by the Input by a possible divider : Yew fPart (A)=0 If the decimal part of has is null… : Then… Then… : P+1→P… One increments the variable… : I→L1 (P)… And one stores the divider in L1 : Fine End of the loop Yew : Fine End of the loop For : Pauses L1 Fin of the program by a pause on the values of L1 (dividers of NR), support on ENTER

To find the roots real of a trinomial function

This program makes it possible to find the roots real of a function of the second degree. It carries out the calculation of the discriminant, and according to this one it calculates the possible roots.

: Disp " FORM AX ² +BX+C" One indicates to the user to what correspond the letters has, B and C asked later : Prompt has, B, C Asks of the 3 numbers thanks to the Prompt one : B ² - 4AC→D Calculation of delta the discriminant : Disp " DELTA=" , D One informs the user of what the discriminant is worth : Yew D<0: Then If D lower than 0, then… : Disp " NO RACINES" writing… : Fine End of the condition : Yew D>0: Then If D higher than 0, then… : Disp " THERE are 2 RACINES" writing… : ((- B+√ (D))/(2A) →E calculation and storage of the first root : ((- B-√ (D))/(2A) →F calculation and storage of the second root : Disp E, F one posts the two roots : Fine End of the condition : Yew D=0: Then If D is equal to 0, then… : Disp " THERE is 1 RACINE" writing… : (- B)/(2A) →G calculation and storage of the root : Disp G one posts the root : Fine End of the condition

Sources

  • Instruction manual of TI-82.

See too

External bonds

  • Instruction manual of the TI-82
  • File of programs BASIC and assembler on computers TI

Random links:Policy of the Democratic republic of Congo | Ormoy (the Essonne) | Special Funds | Workers party of Saint-Christophe-and-Niévès | Hampteau | Chula_Vista,_la_Floride