ti-basic

1.3.4 • Public • Published

TI-Basic Node.js Compiler

Author: finbar
Github: https://github.com/OneAndonlyFinbar/ti-basic.js
NPM: https://www.npmjs.com/package/ti-basic

This module can write TI-Basic code from Node.js.
Note: This does not directly evaluate javascript and convert it to TI-Basic


Quick Start

// Creates a program, prints hello world, compiles file into ./program.txt
const { Program } = require('ti-basic.js');
const program = new Program('./program.txt');
program.print('Hello world!');
program.compile();

Methods

//Create a new program with given file path
new Program('FilePath');

// Print Message to the program
program.print('Message');

// Await a response, and store the value in a variable.
// Returns variable name
program.storeResponse('Variable Name');

// Insert a pause statement to prevent the program from exiting on quit.
program.pause();

//Compiles the program into TI-Basic code.
program.compile();

If/Else Statements

If/else statements can be used to create conditional logic. An example of a program that uses if/else statements is the following:

const program = new Program('./program.txt');
program.print('Enter a number: ');
program.storeResponse('A');
await program.createIfElse({
    condition: 'A=1',
    true: async function(program) {
        await program.print('True');
        await program.stop();
        return program;
    },
    false: async function (program){
        await program.print('False');
        await program.stop();
        return program;
    }
});

In the program above the program will ask for a number user input. If the number equals 1 it will print True to console, otherwise it will print False to console.

if/else Statement functions (true and false) have a program variable passed to them. This variable is the program object for that condition. (true or false)
At the end of the true/false statements be sure to return the program.
The condition is not a regular javascript comparison, but instead a TI-Basic expression. Examples of TI-Basic expressions are below

1=1
A=1
A=B
A=B+C
A=B-C
2>1

Readme

Keywords

none

Package Sidebar

Install

npm i ti-basic

Weekly Downloads

0

Version

1.3.4

License

ISC

Unpacked Size

9.46 kB

Total Files

4

Last publish

Collaborators

  • finbar