eval

Have JavaScript answer calculate into a textbox, not a pop-up!

I have this code in the HEAD: <script LANGUAGE="JavaScript"> <!-- function calculate(form) { height = eval(form.height.value) width = eval(form.width.value) photos = eval(form.photos.value) lgtext = eval(form.lgtext.value) mountlam = eval(form.moun...

Displaying data conditionally within a user control

Within an ASP.NET user control I have the line: <div>Web: <a href="<%# Eval("Web") %>"><%# Eval("Web") %></a></div> I'd like to change it so this HTML is only rendered if Web has a value. I've tried wrapping String.IsNullOrEmpty(Eval("Web") as string) in server side script but Eval can only be used inside a "binding" tag. What is th...

How to execute "eval" without writing "eval" in JavaScript

Here's the deal, we have a big JS library that we want to compress, but YUI compressor doesn't fully compress the code if it finds an "eval" statement, out of fear that it will break something else. That's great and all, but we know exactly what is getting eval'd, so we don't want it to get conservative because there's an eval statement...

Do the math sum of a text variable? (E.g 5865/100 )

I have a variable that is... $whatever = "5865/100"; This is a text variable. I want it to calculate 5865/100 , so that I can add it to other numbers and do a calculation. Number_format doesn't work, as it just returns "5,865". Whereas I want it to return 58.65 I could do... $explode=explode("/",$whatever); if(count($explode)=="2")...

What's the difference between eval, exec, and compile in Python?

I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement. Can someone please explain the difference between eval and exec, and how the different modes of compile() fit in? ...

Converting a string to a JavaScript object - is there a safer way than to use eval?

I'd ideally like to create a streamlined interface which requires the user to select one of three radio buttons such as shown here: <form id="icon-type"> <input type="radio" name="icon" value="apples" /> Apples <input type="radio" name="icon" value="oranges" /> Oranges <input type="radio" name="icon" value="graphes" /> Grape...

JavaScript eval

Why doesn't this alert("Summer")? eval('(caption="Summer";alert(caption))'); Does it have something to do with the quotes in "Summer"? ...

How to suppress time part of a .NET DateTime in display if and only if time part = 00:00:00 ?

In an ASP.NET page I have this: <asp:Label ID="MyDateTimeLabel" runat="server" Text='<%# Eval("MyDateTime") %>' /> I'd like to have it formatted like ... Eval("MyDateTime", "{0:d}") ... // Display only the date if and only if the time part of MyDateTime is 00:00:00. Otherwise like this: ... Eval("MyDateTime", "{0:g}") ... //...

Write Scheme data structures so they can be eval-d back in, or alternative

I'm writing an application (A juggling pattern animator) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will let me "explode" expressions into expressions that can still be eval'd but contain the data as literals for manual tweaking. For example, (4hss->sexp "7...

Best way to convert JSON data to an object in javascript

I am currently using eval in Javscript to convert JSON data returned from the server into an object. eval ("myObject="+data); I've been told that eval is 'evil' and can open up big security problems. I'm wondering - is using eval to convert JSON data to an object the accepted practice? Or is there a better way? Thanks, ...

Are there any use cases where string eval is necessary in Perl?

Can you provide any examples where using eval EXPR is really necessary? I'm asking because its generally discouraged. ...

Why won't this work in PHP?

$constPrefix = '_CONST_'; if (strstr($content, $constPrefix)) { $constants = array('PHP_VERSION', '__FILE__'); foreach($constants as $constant) { $constantOutput = eval($constant); $content = str_replace($constPrefix . $constant, $constantOutput, $content); } } Basically, just trying to parse some content a...

ASP.NET multiple Eval fields

I need to include multiple Eval fields in the Navigate URL field of a hyperlink control, however, the code I have tried does not work. <asp:HyperLink ID="hlkImageLink" runat="server" NavigateUrl='<%# Eval("getProductIDGV","getProductCategoryNameGV","getProductCategoryIDGV", "~/PT_productdetails.aspx?ProductID={0}&amp;CategoryName={1}&am...

What situations demand the use of eval() because there are no alternatives?

I know eval should be avoided in JavaScript for speed and security reasons. But in the case of PHP, rarely is security ever mentioned. More often, it's your program running slower than it should because of a haphazard use of eval. In what specific situations should you use eval because there is no other way around it? For clarity: We'...

Using eval securely to execute functions

def myFunc(arg1, arg2): print "This is a test with " + arg1 + " and " + arg2 while (input != "quit"): input = raw_input("> ") if input != "quit": eval(input) This code gives me a prompt, allowing me to invoke myFunc with parameters I want. I know that eval can be dangerous if a dictionary is not supplied, so I add...

Parameters not getting passed properly

Here's an excerpt of my code: def listFrom(here): print "[DBG] here: " + here def book(here, there, amount): print "[DBG] here: " + here + "; there: " + there + "; amount: " + str(amount) # Code that takes input and stores it into the string input # Yes, I know this is dangerous, but it's part of a # school assignment where w...

Python Eval executing enviroment

I do not understand what environment a eval or exec statement executes in. You can pass both global and local scopes to them but I don't quite understand what this means. Does python create an anonymous module for them, and if that is the case how do the global and local scope differ? Does it run it like it was an anonymous function? ...

How do I test for an exception type in perl?

How can I check what kind of exception caused the script or eval block to terminate? I need to know the type of error, and where the exception occurred. ...

How to use Eval in codebehind to set Page.Title

I have a SQLDataSource that is bound to a ListView control but I want to place parts of the bound record into the HTML TITLE attribute. Here is my codebehind file that I want to change so it can use Eval to construct a dynamic TITLE based on the data content: Public Partial Class zShowAd Inherits System.Web.UI.Page Protected Sub Pa...

Confused by "let" in Clojure

I just started playing with Clojure, and I wrote a small script to help me understand some of the functions. It begins like this: (def *exprs-to-test* [ "(filter #(< % 3) '(1 2 3 4 3 2 1))" "(remove #(< % 3) '(1 2 3 4 3 2 1))" "(distinct '(1 2 3 4 3 2 1))" ]) Then it goes through *exprs-to-test*, evaluates them all, and ...