diff options
-rw-r--r-- | images/emptybox.svg | 32 | ||||
-rw-r--r-- | tajail.py | 3 | ||||
-rw-r--r-- | talogo.py | 18 | ||||
-rw-r--r-- | tasetup.py | 1 |
4 files changed, 48 insertions, 6 deletions
diff --git a/images/emptybox.svg b/images/emptybox.svg index e018a1b..323cff9 100644 --- a/images/emptybox.svg +++ b/images/emptybox.svg @@ -235,6 +235,34 @@ style="stop-color:#ffff00;stop-opacity:1" offset="1" /> </linearGradient> + <linearGradient + x1="0" + y1="0" + x2="104" + y2="21" + id="linearGradient2539" + xlink:href="#linearGradient3166" + gradientUnits="userSpaceOnUse" /> + <linearGradient + id="linearGradient2533"> + <stop + id="stop2535" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop2537" + style="stop-color:#ffff00;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + x1="0" + y1="22" + x2="128.68382" + y2="22" + id="linearGradient2543" + xlink:href="#linearGradient3166" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.75,0,0,0.75,160.75,11.125)" /> </defs> <path d="M 15,37.5 C 11.5,37.5 8,35 5.5,32.5 C 3,30 0.5,26.5 0.5,23 L 0.5,15 C 0.5,11.75 3,6.5 5.5,4.5 C 8,2.5 11.5,0.5 15,0.5 L 751.5,0.5 C 754,0.5 758.5,1.5 762,4.5 C 765.5,7.25 766.5,12 766.5,15 L 766.5,23 C 766.5,26.5 764.5,30 762,32.5 C 759.5,35 755.5,37.5 751.5,37.5 L 15,37.5 z" @@ -321,4 +349,8 @@ y="29" id="tspan2620" style="font-size:24px;fill:#ff0000;fill-opacity:1">???</tspan></text> + <path + d="M 161.5,11.5 L 165.25,11.5 L 165.25,14.5 L 170.5,14.5 L 170.5,11.5 L 239.125,11.5 L 239.125,26.5 L 170.5,26.5 L 170.5,23.5 L 165.25,23.5 L 165.25,26.5 L 161.5,26.5 L 161.5,11.5 z" + id="path2541" + style="fill:url(#linearGradient2543);fill-opacity:1;stroke:none;stroke-width:2;stroke-opacity:1" /> </svg> @@ -19,7 +19,6 @@ #THE SOFTWARE. # a naive approach to running myfun in a jail -import re from time import * from math import * try: @@ -30,7 +29,7 @@ from taturtle import * def myfunc(lc, f, x): # check to make sure no import calls are made - myf = "def f(x): return " + re.sub("import","",f) + myf = "def f(x): return " + f.replace("import","") userdefined = {} try: exec myf in globals(), userdefined @@ -95,8 +95,8 @@ def blocks_to_code(lc,spr): code.append(float(ord(spr.label[0]))) elif spr.proto.name=='string' or spr.proto.name=='title': if type(spr.label) == float or type(spr.label) == int: - #if int(spr.label) == spr.label: - # spr.label = int(spr.label) + if int(spr.label) == spr.label: + spr.label = int(spr.label) code.append('#s'+str(spr.label)) else: code.append('#s'+spr.label) @@ -485,7 +485,7 @@ def lcNew(tw): defprim(lc,'stack', 1, prim_stack, True) defprim(lc,'box1', 0, lambda lc: lc.boxes['box1']) defprim(lc,'box2', 0, lambda lc: lc.boxes['box2']) - defprim(lc,'box', 1, lambda lc,x: lc.boxes['box3'+str(x)]) + defprim(lc,'box', 1, lambda lc,x: box(lc,x)) defprim(lc,'storeinbox1', 1, lambda lc,x: setbox(lc, 'box1',x)) defprim(lc,'storeinbox2', 1, lambda lc,x: setbox(lc, 'box2',x)) defprim(lc,'storeinbox', 2, lambda lc,x,y: setbox(lc, 'box3'+str(x),y)) @@ -522,12 +522,14 @@ def lcNew(tw): lc.istack = [] lc.stacks = {} - lc.boxes = noKeyError({'box1': 0, 'box2': 0}) + # lc.boxes = noKeyError({'box1': 0, 'box2': 0}) + lc.boxes = {'box1': 0, 'box2': 0} lc.heap = [] lc.keyboard = 0 lc.trace = 0 # flag for enabling debug output via showlabel lc.gplay = None lc.ag = None + lc.nobox = "" lc.title_height = int((tw.turtle.height/30)*tw.scale) lc.body_height = int((tw.turtle.height/60)*tw.scale) lc.bullet_height = int((tw.turtle.height/45)*tw.scale) @@ -549,6 +551,13 @@ def lcNew(tw): return lc +def box(lc,x): + try: + return lc.boxes['box3'+str(x)] + except: + lc.nobox = str(x) + raise logoerror("#emptybox") + def loadmyblock(lc,x): # execute code inported from the Journal if lc.tw.myblock != None: @@ -956,6 +965,7 @@ def showlabel(lc,label): if label=='#nostack': shp = 'nostack'; label='' elif label=='#noinput': shp = 'noinput'; label='' elif label=='#emptyheap': shp = 'emptyheap'; label='' + elif label=='#emptybox': shp = 'emptybox'; label=' '+lc.nobox elif label=='#nomedia': shp = 'nomedia'; label='' elif label=='#nocode': shp = 'nocode'; label='' elif label=='#syntaxerror': shp = 'syntaxerror'; label='' @@ -275,6 +275,7 @@ def setup_misc(tw): tw.status_shapes['nostack'] = load_image(tw.path, '', 'nostack') tw.status_shapes['noinput'] = load_image(tw.path, '', 'noinput') tw.status_shapes['emptyheap'] = load_image(tw.path, '', 'emptyheap') + tw.status_shapes['emptybox'] = load_image(tw.path, '', 'emptybox') tw.status_shapes['nomedia'] = load_image(tw.path, '', 'nomedia') tw.status_shapes['nocode'] = load_image(tw.path, '', 'nocode') tw.status_shapes['syntaxerror'] = load_image(tw.path, '', 'syntaxerror') |