Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added long_script.potscr, added interactive shell, made website a lot easier to look at, added multiplication and division, made a function for doing math operations, made potscr logo, did a bunch of other crap to make potscr better
- Loading branch information
James A. Clark
committed
Sep 17, 2021
1 parent
67577b7
commit a0bab32
Showing
10 changed files
with
382 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
~-Please type an integer: _%#%//-That integer plus, minus, times, and divided by 5: _/+%^`%`%^+%>%^&%&%^~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
from sys import stdout | ||
from time import sleep | ||
|
||
storednum = 0 | ||
|
||
def shell(): | ||
global storednum | ||
txtfound = "" | ||
curnum = 0 | ||
lookinfortxt = "" | ||
firstTime = True | ||
stored = "" | ||
shellver = 1.0 | ||
|
||
while True: | ||
curnum = 0 | ||
shellIn = "" | ||
if firstTime: | ||
print(f"potscr shell v{shellver}\n") | ||
print("type 'quit' to exit.") | ||
firstTime = False | ||
|
||
shellIn = input("> ") | ||
if shellIn == "quit" or shellIn == "q" or shellIn == "bye" or shellIn == "exit": | ||
exit() | ||
|
||
# code in potscr.py starts here | ||
|
||
def mathsomethin(type): | ||
global storednum | ||
try: | ||
if shellIn[curnum+1] == "%": | ||
if shellIn[curnum+2].isnumeric(): | ||
if type == "+": | ||
storednum += int(shellIn[curnum+2]) | ||
elif type == "-": | ||
storednum -= int(shellIn[curnum+2]) | ||
elif type == "*": | ||
storednum = storednum * int(shellIn[curnum+2]) | ||
elif type == "/": | ||
storednum = storednum / int(shellIn[curnum+2]) | ||
else: | ||
if type == "+": | ||
storednum += 5 | ||
elif type == "-": | ||
storednum -= 5 | ||
elif type == "*": | ||
storednum = storednum * 5 | ||
elif type == "/": | ||
storednum = storednum / 5 | ||
except IndexError: | ||
if type == "+": | ||
storednum += 1 | ||
elif type == "-": | ||
storednum -= 1 | ||
elif type == "*": | ||
storednum = storednum * 1 | ||
elif type == "/": | ||
storednum = storednum / 1 | ||
|
||
|
||
|
||
for i in range(0,shellIn.__len__()): | ||
char = shellIn[curnum] | ||
if char == "-": # start of print | ||
lookinfortxt = True | ||
elif char == "_": # end of print | ||
lookinfortxt = False | ||
try: | ||
if shellIn[curnum+1] == "%": # percentage after means an alt version of the command, in this case no newline | ||
stdout.write(txtfound[1:]) | ||
stdout.flush() | ||
txtfound = "" | ||
else: | ||
print(txtfound[1:]) | ||
txtfound = "" | ||
except IndexError: | ||
print(txtfound[1:]) | ||
txtfound = "" | ||
elif char == "#": # get input | ||
temp = input() | ||
try: | ||
if temp.isnumeric() and shellIn[curnum+1] == "%": | ||
storednum = int(temp) | ||
elif shellIn[curnum+1] == "%" and not temp.isnumeric(): | ||
print("ERROR: Input must be an integer!") | ||
exit() | ||
else: | ||
stored = temp | ||
except: | ||
stored = temp | ||
|
||
elif char == "$": # print stored var | ||
print(stored,end="") | ||
elif char == "/": # newline | ||
print("") | ||
elif char == "*": # reset stored number | ||
storednum = 0 | ||
elif char == "+": # number + | ||
mathsomethin("+") | ||
elif char == "`": # number - | ||
mathsomethin("-") | ||
elif char == ">": # number multiplied | ||
mathsomethin("*") | ||
elif char == "&": # number divided | ||
mathsomethin("/") | ||
elif char == "^": # print stored num | ||
try: | ||
if shellIn[curnum+1] == "%": | ||
print(storednum,end="") | ||
else: | ||
print(storednum) | ||
except IndexError: | ||
print(storednum) | ||
|
||
elif char == "@": # sleep | ||
try: | ||
sleep(int(shellIn[curnum+1])) | ||
except ValueError: | ||
print(f"\nERROR: Char {curnum}: An integer is required for sleeping") | ||
exit() | ||
|
||
|
||
|
||
if lookinfortxt: | ||
txtfound += char | ||
|
||
curnum += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<style> | ||
h1{ | ||
color:sienna; | ||
font-family: "Segoe UI"; | ||
font-size: 45px; | ||
} | ||
|
||
</style> | ||
|
||
|
||
<head> | ||
<title>potatoscript - home</title> | ||
<link rel="icon" type="image/png" href="website/favicon.png"/> | ||
<link rel="icon" type="image/png" href="website/img/favicon.png"/> | ||
<link rel="stylesheet" type="text/css" href="website/css/style.css"/> | ||
</head> | ||
<body> | ||
<h1>potatoscript</h1> | ||
<img src="website/img/potscr.png"> | ||
<!--<h1>potatoscript</h1>!--> | ||
<h2>potatoscript is an esoteric programming language, similar to unlambda.</h3> | ||
<a href="website/guide.html">potatoscript programming guide</a> | ||
<a href="website/guide.html"><button>potatoscript programming guide</button></a> | ||
<p></p> | ||
<a href="website/cli.html">cli usage guide</a> | ||
<a href="website/cli.html"><button>cli usage guide</button></a> | ||
</body> | ||
</html> |
Oops, something went wrong.