From 5218ffdac0a504cbd0c1b229ac899db9b7f9771c Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Mon, 20 Jul 2009 21:22:02 +0000 Subject: ëmpty box error message --- 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" /> + + + + + + ??? + diff --git a/tajail.py b/tajail.py index e2b1c85..64ec02e 100644 --- a/tajail.py +++ b/tajail.py @@ -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 diff --git a/talogo.py b/talogo.py index 892993a..e955adf 100644 --- a/talogo.py +++ b/talogo.py @@ -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='' diff --git a/tasetup.py b/tasetup.py index 440b08c..6899067 100644 --- a/tasetup.py +++ b/tasetup.py @@ -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') -- cgit v0.9.1