Skip to content

Commit 3a86105

Browse files
Add files via upload
1 parent b0c391a commit 3a86105

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

PyBasic/PyBasic.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
from sys import print_exception
3939

4040
gc.collect()
41-
if implementation.name.upper() == 'MICROPYTHON':
41+
if 'threshold' in dir(gc):
4242
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
4343

44-
def main():
44+
def main(passedIn=""):
4545

4646
banner = (
4747
"""
@@ -117,8 +117,7 @@ def main():
117117
remove('_pybTmp.tmp')
118118
break
119119

120-
# Add a new program statement, beginning
121-
# a line number
120+
# Add a new program statement
122121
elif tokenlist[0].category == Token.UNSIGNEDINT\
123122
and len(tokenlist) > 1:
124123
program.add_stmt(tokenlist,-1,tmpfile)
@@ -246,23 +245,20 @@ def main():
246245
else:
247246
print("Program file not found")
248247

249-
# Unrecognised input
250248
else:
251249
print("Unrecognized input")
252250
for token in tokenlist:
253251
token.print_lexeme()
254252
print("")
255253

256-
# Trap all exceptions so that interpreter
257-
# keeps running
254+
# Trap all exceptions so that interpreter keeps running
258255
except Exception as e:
259256
if implementation.name.upper() == 'MICROPYTHON':
260-
#### print(e)
261257
print_exception(e)
262258
else:
263259
print(e)
264260

265-
if __name__ != "PyDOS":
266-
passedIn = ""
267-
268-
main()
261+
if __name__ == "PyDOS":
262+
main(passedIn)
263+
else:
264+
print("Enter 'PyBasic.main()' in the REPL to run.")

PyBasic/basicparser.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ def __simplestmt(self,infile,tmpfile,datastmts):
281281
return None
282282

283283
elif self.__token.category == Token.DIM:
284-
#gc.collect()
285-
#if implementation.name.upper() == 'MICROPYTHON':
286-
#gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
287284
self.__dimstmt()
288285
return None
289286

@@ -908,11 +905,8 @@ def __soundstmt(self):
908905
elif implementation.name.upper() == 'CIRCUITPYTHON':
909906
try:
910907
Pydos_hw.sndGPIO.deinit() # Workaround for ESP32-S2 GPIO issue
911-
audioPin = PWMOut(sndPin, duty_cycle=0, frequency=440, variable_frequency=True)
912-
audioPin.frequency = freq
913-
audioPin.duty_cycle = volume
908+
audioPin = PWMOut(sndPin, duty_cycle=volume, frequency=freq, variable_frequency=True)
914909
sleep(duration/18.2)
915-
audioPin.duty_cycle = 0
916910
audioPin.deinit()
917911
Pydos_hw.quietSnd() # Workaround for ESP32-S2 GPIO issue
918912
except:

PyBasic/eliza.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
180 REM *******USER INPUT SECTION**********
3131
190 REM ***********************************
3232
200 INPUT I$
33-
201 I$ = " " + I$ + " "
33+
201 I$ = " " + UPPER$(I$) + " "
3434
210 REM GET RID OF APOSTROPHES
3535
220 FOR L = 1 TO LEN ( I$ )
3636
230 REM IF MID$(I$,L,1)="'"THEN I$=MID$(I$, 1 ,L-1)+MID$(I$,L+1,LEN(I$)-L):GOTO 230

PyBasic/program.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ def execute(self,infile,tmpfile):
300300
# sequential statement execution. The index
301301
# will be incremented by one, unless modified by
302302
# a jump
303-
#gc.collect()
304-
#if implementation.name.upper() == 'MICROPYTHON':
305-
#gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
306303
index = 0
307304
self.set_next_line_number(line_numbers[index])
308305

0 commit comments

Comments
 (0)