storage
Save bytes in AppVars, which stay on the calculator between runs. storage and
file are one library under two names, with the same methods on every
target.
from ti84 import storage
storage.create("SCORES", 1)
best = storage.read_byte("SCORES", 0)
if score > best:
storage.write_byte("SCORES", 0, min(score, 255))
AppVar names must be string literals: 1-8 letters or digits, starting with a letter. They are converted to upper case.
Errors
Warning
On assembly targets, read_byte() and write_byte() end the program if the
AppVar is missing or the offset is out of range. write_byte() also does so if the
AppVar is archived. Call create() first.
Archived AppVars can be read on CE, but not on classic. They cannot be written on either target.
Methods
- exists(name) bool
Whether an AppVar exists.
- Targets:
CE, Classic, Flash App
z = storage.exists('SAVE')
- size(name) int
An AppVar’s size in bytes, or 0 if missing.
- Targets:
CE, Classic, Flash App
z = storage.size('SAVE')
- create(name, size)
Create a zero-filled AppVar unless it already exists.
- Targets:
CE, Classic, Flash App
storage.create('SAVE', x)
- delete(name)
Delete an AppVar if it exists.
- Targets:
CE, Classic, Flash App
storage.delete('SAVE')
- clear(name)
Zero every byte of an AppVar.
- Targets:
CE, Classic, Flash App
storage.clear('SAVE')
- read_byte(name, offset) int
Read a byte.
- Targets:
CE, Classic, Flash App
z = storage.read_byte('SAVE', x)
- write_byte(name, offset, value)
Write a byte.
- Targets:
CE, Classic, Flash App
storage.write_byte('SAVE', x, y)
- read_u16(name, offset) int
Read a little-endian 16-bit value.
- Targets:
CE, Classic, Flash App
z = storage.read_u16('SAVE', x)
- write_u16(name, offset, value)
Write a little-endian 16-bit value.
- Targets:
CE, Classic, Flash App
storage.write_u16('SAVE', x, y)