eval

How can I evaluate a C# expression dynamically?

I would like to do the equivalent of: object result = Eval("1 + 3"); string now = Eval("System.DateTime.Now().ToString()") as string Following Biri s link, I got this snippet (modified to remove obsolete method ICodeCompiler.CreateCompiler(): private object Eval(string sExpression) { CSharpCodeProvider c = new CSharpCodeProvid...

Best Technique for Multiple Eval Fields in Gridview ItemTemplate?

What is the best way to use multiple EVAL fields in a GridView ItemTemplate? Looking to have some control over formatting for appearance as well as setting up hyperlinks/javascript etc. ...

Why is using Javascript eval function a bad idea?

The eval function is a powerful and easy way to dynamically generate code so what are the caveats? ...

What is the scope for imported classes in python?

Please excuse the vague title. If anyone has a suggestion, please let me know! Also please retag with more appropriate tags! The Problem I want to have an instance of an imported class be able to view things in the scope (globals, locals) of the importer. Since I'm not sure of the exact mechanism at work here, I can describe it much...

Eval scripts in server side control property

how do i implement an eval script in a sever side control? eg. <a runat="server" href="?id=<%= Eval("Id") %>">hello world</a> ...

When is JavaScript's eval() not evil?

I'm writing some JavaScript to parse user-entered functions (for spreadsheet-like functionality). Having parsed the formula I could convert it into JavaScript and run eval() on it to yield the result. However, I've always shied away from using eval() if I can avoid it because it's evil (and, rightly or wrongly, I've always thought it is ...

Are Dynamic Prepared Statements Bad? (with php + mysqli)

I like the flexibility of Dynamic SQL and I like the security + improved performance of Prepared Statements. So what I really want is Dynamic Prepared Statements, which is troublesome to make because bind_param and bind_result accept "fixed" number of arguments. So I made use of an eval() statement to get around this problem. But I ge...

Creating a lambda from an s-expression

I have an s-expression bound to a variable in Common Lisp: (defvar x '(+ a 2)) Now I want to create a function that when called, evaluates the expression in the scope in which it was defined. I've tried this: (let ((a 4)) (lambda () (eval x))) and (let ((a 4)) (eval `(lambda () ,x))) But both of these create a problem: EVAL...

In PHP, is there a way to capture the output of a PHP file into a variable without using output buffering?

In PHP, I want to read a file into a variable and process the PHP in the file at the same time without using output buffering. Is this possible? Essentially I want to be able to accomplish this without using ob_start(): <?php ob_start(); include 'myfile.php'; $xhtml = ob_get_clean(); ?> Is this possible in PHP? Update: I want to do ...

Escaping dilemma in Javascript.

Hi everyone, I have the following var id='123'; newDiv.innerHTML = "<a href=\"#\" onclick=\" TestFunction('"+id+"', false);\"></a>"; Which renders <a href="#" onclick="return Testfunction('123',false);"></a> in my HTML. The problem I have is that I wish to take the call to the method TestFunction, and use as a string parameter in m...

How to use Single Quotes in Eval Format String

I've got a Repeater and its SqlDatasource nested inside a Gridview TemplatedField. The Repeater's datasource SelectCommand is set using the FormatString of an Eval from the Gridview. The SelectCommand has a WHERE clause which is to compare a string. Because I have already used the single and double quotes, I am having trouble delimiting ...

<%# Eval("State") %> or <%# DataBinder.Eval(Container.DataItem, "state")%>

What is the difference between having <%# Eval("State") %> in your aspx page or <%# DataBinder.Eval(Container.DataItem,"state") %> in your aspx page? Thanks, X ...

Setting variables by name in Java

I'm looking to implement something in Java along the lines of: class Foo{ private int lorem; // private int ipsum; public setAttribute(String attr, int val){ //sets attribute based on name } public static void main(String [] args){ Foo f = new Foo(); f.setAttribute("lorem",1); f.setAttribute("ipsum",2); } public ...

Why does my script report 'uninitialized value in eval "string"?

I am getting this warning: Use of uninitialized value in eval \"string\" at myscript.pl line 57. When I run this code: eval; { `$client -f $confFile -i $inputFile -o $outputFile`; }; if( $@ ) { # error handling here ... } What is causing the error? How can I fix the underlying cause? (Or otherwise suppress the war...

PHP's create_function() versus just using eval()

In PHP you have the create_function() function which creates a unique named lambda function like this: $myFunction = create_function('$foo', 'return $foo;'); $myFunction('bar'); //Returns bar Is this actually any better (apart from being more easy) then just doing: do{ $myFunction = 'createdFunction_'.rand(); } while(function_exist...

Php and macros(lisp style)?

Hi im learning LISP and well, all day i program php for a living, so i was messing around with php.net and found the eval function... so i started playing around! I would love to know more about how to use eval to do crazy stuff, i know you can make functions with this and everything... but i wanted to ask why the next code wont work: ...

Wordpress Category ID vs Eval Issue

Hi Ok this is a little complex. I am creating a plugin, and want to find the category ID from the Post page. That's the easy part. What makes it complex is I am doing it within an ob_start (started in a 'template_redirect' action) as I want to edit the full page before it is returned to the browser. Again that is easy enough from the ...

Does threading behaviour of eval() vary across different browsers?

I am currently logging an AJAX application with messages which include the times of certain interactions. So I have a couple of places where the code follows a pattern such as this: var startTime = new Date(); this.doFunction(); var endTime = new Date(); logger.log("doFunction took " + (endTime - startTime) + " milliseconds."); What...

How can I work around the fact that I can't put a code block in a skin file?

I have a asp.net page I'm writing and I'm perplexed by this problem. I have 3 DetailViews that I bind with LINQ. The binding works great. Now, I have a Skin file that I want to use to layout the DVs, and it looks like this. <asp:DetailsView SkinID="blogViews" runat="server" Width="100%" CssClass="post" AutoGenerateRows="False" GridLine...

Repeater's SeparatorTemplate with Eval

Hi, is it possible to use Eval or similar syntax in the SeparatorTemplate of a Repeater? Id' like to display some info of the last item in the separator template like this: <table> <asp:Repeater> <ItemTemplate> <tr> <td><%# Eval("DepartureDateTime") %></td> <td><%# Eval("ArrivalDa...