A C++ "library" to interact with TI-Z80/eZ80 (82/83/84 series) calculators files (programs, lists, matrices...).
JavaScript bindings (for use with emscripten) are provided for convenience.
Right now, the best documentation is the tests file itself, which uses the main API methods.
Basically, though, there are loading/saving/conversion (data->string, string->data) methods you just have to call.
Example 1: Here's how to read the source of TI-Basic program from an .8xp file and print it:
auto myPrgm = TIVarFile::loadFromFile("the/path/to/myProgram.8xp");
auto basicSource = myPrgm.getReadableContent(); // You can pass options like { {"reindent", true} }...
std::cout << basicSource << std::endl;Example 2: Here's how to create a TI-Basic program (output: .8xp file) from a string:
auto newPrgm = TIVarFile::createNew("Program"); // Create an empty "container" first
newPrgm.setVarName("TEST"); // (also an optional parameter above)
newPrgm.setContentFromString("ClrHome:Disp \"Hello World!\""); // Set the var's content from a string
newPrgm.saveVarToFile("path/to/output/directory/", "myNewPrgrm"); // The extension is added automaticallySeveral optional parameters for the functions are available. For instance, French input/output for tokenized content can be selected with an options map such as { {"lang", TH_Tokenized::LANG_FR} }, and pretty-printing can enable reindentation with { {"reindent", true} }.
Note: The code throws exceptions for you to catch in case of trouble.
Bindings are done for the necessary classes, so it should be pretty obvious.
Integration example:
<script type="module">
import TIVarsLib from './TIVarsLib.js';
const lib = await TIVarsLib();
const prgm = lib.TIVarFile.createNew("Program", "TEST");
prgm.setContentFromString("ClrHome:Disp \"Hello World!\"");
const filePath = prgm.saveVarToFile("", "MyTestProgram");
const file = lib.FS.readFile(filePath, {encoding: 'binary'});
...
</script>You can find code that use this project as a JS lib here: https://github.com/TI-Planet/zText (look at generator.js)
| Vartype | data->string | string->data |
|---|---|---|
| Real | ✓ | ✓ |
| Real List | ✓ | ✓ |
| Matrix | ✓ | ✓ |
| Equation | ✓ | ✓ |
| String | ✓ | ✓ |
| Program | ✓ | ✓ |
| Protected Program | ✓ | ✓ |
| Graph DataBase (GDB) | ✓ (JSON) | ✓ (JSON) |
| Complex | ✓ | ✓ |
| Complex List | ✓ | ✓ |
| Window Settings | ✓ (JSON) | ✓ (JSON) |
| Recall Window | ✓ (JSON) | ✓ (JSON) |
| Table Range | ✓ (JSON) | ✓ (JSON) |
| Picture | ✓ (JSON metadata) | |
| Image | ✓ (JSON metadata) | |
| Application Variable | ✓ | ✓ |
| Python AppVar | ✓ | ✓ |
| Group Object | ✓ (JSON) | ✓ (JSON) |
| Exact Complex Fraction | ✓ | ✓ |
| Exact Real Radical | ✓ | ✓ |
| Exact Complex Radical | ✓ | ✓ |
| Exact Complex Pi | ✓ | ✓ |
| Exact Complex Pi Fraction | ✓ | ✓ |
| Exact Real Pi | ✓ | ✓ |
| Exact Real Pi Fraction | ✓ | ✓ |
| Operating System / Flash App / Certificate | ✓ (JSON metadata) |
Special vartype naming rules are implemented for constrained names such as strings, lists, matrices, equations, pictures, images, GDBs, and settings vars.
Picture/image support is currently read-only and exposes metadata as JSON; raw pixel import/export is not implemented. Flash file support is currently read-only and exposes header/object metadata as JSON.
To this date, there are no plans to support other types (except maybe some fancy things with the image/picture vartypes...).
Pull Requests are welcome, though :)