eval

How can I use external variables in eval in Scheme?

I am trying something out in Scheme for fun. I'm trying to make an Area function that gets the type of the thing it's operating on and then calls a different function depending on the type of object. Here's my code: (define (area object) (if (not (null? (eval (word 'area- (get-type object))))) (eval (list (word 'area- (get-typ...

Setting content Page.Title dynamically from blog post title

I'm building a tiny blog app, and what I need to do is show blog post title for dynamically generated content page Item.aspx in page title. In other words, i need data that is bound to this label in FormView to also be shown in page title when page loads. <asp:Label ID="lblPostTitle" runat="server" Text='<%# Eval("PostTitle") %>' /> ...

How to affect differences in row content when binding a dataset to a ListView in ASP.NET 3.5

I have added a ListView to a web form and this code works when the data columns in the bound dataset have values: <asp:ListView ID="picturesListView" runat="server" GroupPlaceholderID="groupsGoHere" ItemPlaceholderID="itemsGoHere" GroupItemCount="1" > <LayoutTemplate> <p id="pictureList">Picture List:</p> ...

AS3 I need to convert a string from input to a as3 object

function send(input):void{ // input.text = "{key: 'value'}" var x:* = stringToObject(input.text) // then be able to do this var y:* = x.key; // then y must be equal to 'value' trace(y) // this is just a string } ...

What risk or liablities in using eval() in the following manner

I'm working on creating one of those robot games. The user creates a robot and then puts it in a battlefield with other robots. I'd like to let the users use javascript to program their bots. I'll provide a number of functions for them to call, but they also can build thier own. (sorta) To date, the only solution I have come up with is...

How do i return eval(code) and get an object back with javascript

I have this bit of code. What I want it to do is is load a .js file and then run it. when it runs i want it to return a parameter or even better an object. This is the code in my page var runCode = function(){ var xhr=new XMLHttpRequest(); xhr.open('GET','io.js',false); xhr.send(); return eval(xhr.responseText); }; An...

EXTjs - Eval multi json elements

Hi, I want to take some data from the server and eval it. if i eval 1 element in the json, it works fine, but if i eval more, i get an error this is the operation (Using jquery for the ajax): ,getColsFromServer : function(){ return [new Ext.grid.RowNumberer(), Ext.util.JSON.decode('{"id":"id","dataIndex":"id","header":...

Dirt-simple PHP templates... can this work without `eval`?

Update- Thanks for all the responses. This Q is getting kind of messy, so I started a sequel if anyone's interested. I was throwing together a quick script for a friend and stumbled across a really simple way of doing templating in PHP. Basically, the idea is to parse the html document as a heredoc string, so variables inside of it ...

Javascript eval() for function with argument

How do I do this? function myUIEvent() { var iCheckFcn = "isInFavorites"; var itemSrc = ui.item.find("img").attr("src"); if (eval(iCheckFcn(itemSrc))) { alert("it's a favorite"); } function isInFavorites(url) { return true; } // returns boolean ...

Python - Creating a "scripting" system

Hello, I'm making a wxpython app that I will compile with the various freezing utility out there to create an executable for multiple platforms. the program will be a map editer for a tile-based game engine in this app I want to provide a scripting system so that advanced users can modify the behavior of the program such as modifying p...

Creation of an object inside names<-() gives an error. How to explain?

Hi everyone, This x <- list(12, 13) names(y <- x) <- c("a", "b") gives the error: Error in names(y <- x) <- c("a", "b") : object 'y' not found Can anyone explain why? According to R's rules of evaluation y <- x should be evaluated inside the parent frame of names<-. So y should be created in global environment. Thanks. [upda...

Python. Transform str('+') to mathematical operation.

How transform str('+') to mathematical operation? For example: a = [0,1,2] # or a = ['0','1','2'] b = ['+','-','*'] c = int(a[0]+b[0]+a[1]) In other words, how transform str('-1*2') to int(), without for i in c: if i == '+': ... Thanks. ...

Why I can call 'print' from 'eval'

For code: #!/usr/bin/python src = """ print '!!!' import os """ obj = compile(src, '', 'exec') eval(obj, {'__builtins__': False}) I get output: !!! Traceback (most recent call last): File "./test.py", line 9, in <module> eval(obj, {'__builtins__': False}) File "", line 3, in <module> ImportError: __import__ not found Bot...

Eval/Bind TimeOfDay property without milliseconds?

Hi all, I'm trying to format the following: <%# Bind("TimeOfDay","{0:HH:mm:ss}") %> <%# Eval("TimeOfDay","{0:HH:mm:ss}") %> <%# Bind("TimeOfDay","{0:HH:mm:ss tt}") %> But using either of those returns time as following: 08:33:08.1430000 How can I only get the 08:33:08 part? Thanks, EtonB. ...

eval is evil issue

Using JSlint to validate my javascript. I am getting an error saying eval is evil! Why is this and is there an alternative I can use? Here is an example of where I am using eval and would like a workaround for it. I have an array like this: var Resources = { message_1: 'Message 1', message_2: 'Message 2', message_3: 'Message 3', mess...

Eval() and base class properties

I have class Foo which defines property Id. Class Bar inherits from Foo (class Bar : Foo). If I assign a List<Bar> to Repeater.DataSource then use Eval("Id") in the ItemTemplate, the following exception is thrown: DataBinding: 'Bar' does not contain a property with the name 'Id'. Any way around this? Id is a valid property of Bar...

What is the best way to handle exceptions in perl?

I've noticed that Exception.pm and Error.pm don't seem to be extensively used in the perl community. Is that due to the large footprint of eval for exception handling? Also perl programs appear to have a much more lenient policy regarding exception handling in general. Is there a compelling reason for this? In any event what would be...

javascript eval and object evaluation

I have a part of a debugging framework that needs to be able to run time eval objects. Specifically, if I have a string like this "{a: 1, b:2}" it needs to evaluate it into an object with members a and b with those values. However, if I do eval("{a: 1, b:2}") it seems to evaluate it as a statement, and says something about an illegal la...

Process mathematical equations in php

A user is allowed to enter any mathematical equation they like (with one variable): x + 5 1 - x/2 (x/3) * (56/13) These are stored as strings in the database. When they are retrieved I need to substitute 'x' for a number and check the value of the equation. How could I do this? I was considering writing a parser to deconstruct the...

Can php eval return a boolean value?

I cant seem to get eval to return a boolean value for '(4 > 5)' Is this possible? If not how might I get this to work (without writing a parser) I have tried this: $v = eval('return (10 > 5)'); var_dump($v); // Result = bool(false) UPDATE Thanks to @Pekka - I added a semicolon to the above code and it works. ...