Skip to content

Commit

Permalink
Output
Browse files Browse the repository at this point in the history
  • Loading branch information
TabulateJarl8 committed Feb 5, 2021
1 parent 6f1a48a commit 49005e8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,25 @@ ti842py is a TI-BASIC to Python 3 transpiler. A transpiler is a piece of softwar
- `Goto`
- `Lbl`
- `getDate` and `getTime`
<!-- - [`Goto`](#goto)
- [`Lbl`](#goto)-->
- `Output()`

### Planned Features
- `IS>(`
- `DS<(`
- `Return`
- `eval()`/`expr()`
- `toString()`
- `Output()`
- `Ans`
- `Menu()`
- List subscripting
- Indentation with `:`

# Installation

----

ti842py can be installed via PyPI or by cloning the repository. To install it with PyPI, just run `pip3 install ti842py` in a terminal. To install it locally, you can clone the repository and run `python setup.py install --user`.

<!--### <a name="goto"></a>Goto:
To have support for goto and lbl, you need to run `pip3 install git+https://github.com/TabulateJarl8/python-goto.git@patch-2`. This is because PyPI will not allow users to install packages from outside sources.-->

# Usage

----
Expand Down
5 changes: 3 additions & 2 deletions program.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ End
Disp "J=",J
Pause "PRESS ENTER"
Disp "NOW WAIT"
Wait 5
Prompt X
Wait 2
Prompt X
Output(70, 1, "HI"
2 changes: 1 addition & 1 deletion ti842py/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = "ti842py"
__description__ = "TI-BASIC to Python 3 Transpiler"
__url__ = "https://github.com/TabulateJarl8/ti842py"
__version__ = "0.1.11"
__version__ = "0.1.12"
__author__ = "Tabulate"
__author_email__ = "[email protected]"
__license__ = "GPLv3"
Expand Down
10 changes: 10 additions & 0 deletions ti842py/tiParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ def toPython(self):
elif line.startswith("Lbl "):
statement = "label .lbl" + line[4:]
self.UTILS["goto"]["enabled"] = True
# Output
elif line.startswith("Output("):
statement = line[7:]
statement = statement.split(",")
if statement[-1].count("\"") > 1:
statement[-1] = re.findall('"([^"]*)"', statement[-1])[0]
else:
statement[-1] = statement[-1].strip(" ")[1:]
statement = "output(" + statement[1].strip(" ") + ", " + statement[0].strip(" ") + ", \"" + statement[-1] + "\")"
self.UTILS["output"]["enabled"] = True
else:
statement = "# UNKNOWN INDENTIFIER: {}".format(line)
logger.warning("Unknown indentifier on line %s", index)
Expand Down
5 changes: 5 additions & 0 deletions ti842py/utils/output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import sys

def output(x, y, text):
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
sys.stdout.flush()

0 comments on commit 49005e8

Please sign in to comment.