Thanks, but with the sped of today's computers I am not at all concerned that the eval command is slightly slow, I use it a lot because we need to have publicly accessible ID's for each control that I create on the fly and things run quite well.
Right now I am just interested in finding out why this code results in a total break. It's as if there is a null value in it and the file is truncating prematurely. I think I'll hit the file with a hex editor and see if there are any odd characters that I can't see. Thanks, Jim On Wed, Mar 9, 2011 at 10:27 PM, Tobias Oetiker <[email protected]> wrote: > Hi Jim, > > Yesterday Jim Hunter wrote: > >> I have a large app that has not given me much trouble lately until >> this... I have a switch statement and when I just had code for the >> first item, the statement worked fine, when I added the exact same >> line to the second statment, the file fails to even load in the >> browser! Can someone take a quick look to see if I am overlooking an >> obvious mistake here? Here is the code that works fine: >> >> >> switch (ofdShape) >> { >> case "Rectangle" : >> eval("var " + id + " = this.paper.rect(" + (X >> * ofdWidth) + ", " + >> (Y * ofdHeight) + ", nodeWidth, nodeHeight).attr({fill: fillColor, >> stroke: borderColor, 'stroke-width': 2})"); >> break; >> case "RoundRect" : >> case "Diamond" : >> case "Ellipse" : >> } >> >> >> and here is the code that breaks everything: >> >> >> switch (ofdShape) >> { >> case "Rectangle" : >> eval("var " + id + " = this.paper.rect(" + (X >> * ofdWidth) + ", " + >> (Y * ofdHeight) + ", nodeWidth, nodeHeight).attr({fill: fillColor, >> stroke: borderColor, 'stroke-width': 2})"); >> break; >> case "RoundRect" : >> eval("var " + id + " = this.paper.rect(" + (X >> * ofdWidth) + ", " + >> (Y * ofdHeight) + ", nodeWidth, nodeHeight).attr({fill: fillColor, >> stroke: borderColor, 'stroke-width': 2})"); >> break; >> case "Diamond" : >> case "Ellipse" : >> } >> >> With the second piece of code, I just get a white screen in the >> browser when I try and start the program. When I look in FireBug, the >> JS file fails to complete the load process. If I go in to the build >> script and comment out the added line, the file loads fine. If I >> replace the line with something like 'alert("hello")' it works fine. >> >> This one has me scratching my head and I am totally stumped. > > why it breaks, I don't know, but using eval like this a sub-optimal > aproach ... can't you use a map instead of conjuring up > variables on the fly ... I bet this will be very unhealthy for > performance as the eval bits would probably resist compilation > > cheers > tobi > > >> Thanks, >> Jim >> >> ------------------------------------------------------------------------------ >> Colocation vs. Managed Hosting >> A question and answer guide to determining the best fit >> for your organization - today and in the future. >> http://p.sf.net/sfu/internap-sfd2d >> _______________________________________________ >> qooxdoo-devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel >> >> > > -- > Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland > http://it.oetiker.ch [email protected] ++41 62 775 9902 / sb: -9900 > > ------------------------------------------------------------------------------ > Colocation vs. Managed Hosting > A question and answer guide to determining the best fit > for your organization - today and in the future. > http://p.sf.net/sfu/internap-sfd2d > _______________________________________________ > qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel > ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
