Questions tagged [eval]

eval is a function that allows a programmer to execute arbitrary code written in the same language, from a string variable within a code.

eval
Filter by
Sorted by
Tagged with
0 votes
1 answer
302 views

Alternative to calling eval on JSON for function storage?

Problem I'm writing a javascript library for skeletal animations on canvas, and I want to be able to encapsulate entities as JSON data. For example, if I want to draw a minotaur, I simply fetch ...
Josh's user avatar
  • 338
0 votes
0 answers
41 views

How to get images photo gallery?

I want to do an image gallery, but photos are not coming from the database. I can only see one picture whereas it should have many different photos... <asp:Panel ID="Panel1" runat="server"> ...
Zulfikar Bakır's user avatar
0 votes
1 answer
110 views

Why do I get an undefined value if the value is defined? using eval()

I cant quite figure out why I am getting an undefined in my console... Each object being iterated over has the property defined. Where did I go wrong?? the collection looks like this: var a = [ ...
user avatar
3 votes
1 answer
345 views

Can I write this macro without using eval?

I'm trying to write a macro which will catch a compile time error in Clojure. Specifically, I would like to catch exceptions thrown when a protocol method, which has not been implemented for that ...
dmh's user avatar
  • 183
1 vote
1 answer
338 views

Eval and function scope

Something seems wrong with the following code. It declares a function with eval, calls it — until then, everything is fine — and, calls it again but, though a function and thus gets an error. var fn =...
yves amsellem's user avatar
4 votes
1 answer
2k views

Is there an equivalent to Python's exec() function in Java?

In python, you can use exec() to execute a piece of code. Is there's any way to do this in Java, so that I can call a function from a string, but also do other things as-well like getting some user ...
ZacG's user avatar
  • 97
23 votes
2 answers
11k views

Use of variables like %{buildDir} in QtCreator kit settings in Qt5

In this documentation (under section "Specifying a Custom Executable to Run") I noticed that there is mention of what looks like a variable %{buildDir} in the field "Working directory". I have ...
Mr. Developerdude's user avatar
0 votes
0 answers
1k views

Eval command does not come with Cygwin?

I'm trying to run a Nodejs project imported from my friend's repo. He uses Mac and I use windows. It works perferctly on his laptop but not on mine. When I start the server, there are some commands ...
E.Liu's user avatar
  • 1
0 votes
2 answers
2k views

Javascript eval returning wrong value [duplicate]

I am trying to use eval() for calculator i am making, but if when i try this console.log(eval("5.2-5")); It returns 0.20000000000000018 Why is this happening.Thank you for your time.
August's user avatar
  • 1,789
0 votes
0 answers
40 views

Replace "eval" in vectors created inside a loop in MATLAB

I created a GUI that requests info from the user, which is then saved into series of variables (e.g. Fp1, Sn1, Fp2, Sn2, Fp3, Sn3...) and into different files (Info1.mat, Info2.mat, Info3.mat...). ...
alonsof12's user avatar
0 votes
1 answer
574 views

eval() function in PHP, how to make this work properly on the website?

I have a problem with eval() function. Please do not comment something like "Don't use eval" or anything of this kind of thing, as this is not helpful. I have a very good reason to use eval(). ...
pokrak94's user avatar
  • 202
5 votes
2 answers
4k views

Is there an equivalent of eval for css styles?

I have a style element that is loaded from an external resource, and I want to apply it's styles without putting it inline. For instance <link rel="stylesheet" type="text/css" href="my.css" /> ...
Seph Reed's user avatar
  • 9,742
0 votes
1 answer
276 views

How to import css dynamically with js?

I got some condition, so I can not load some css, js in html. So I decide that pulling dynamically with $.get(). However, I tested js case, but do not have any clues in case of css. Following is ...
Juneyoung Oh's user avatar
  • 7,482
0 votes
0 answers
40 views

How do I embed a Java compiler&runner into a JVM-based program?

I want user to be able to input a snippet of code with a class or function implemented in Java and the program should run this code, without referring to external tools like javac or saving class ...
Vi.'s user avatar
  • 37.9k
47 votes
7 answers
18k views

Python eval: is it still dangerous if I disable builtins and attribute access?

We all know that eval is dangerous, even if you hide dangerous functions, because you can use Python's introspection features to dig down into things and re-extract them. For example, even if you ...
asmeurer's user avatar
  • 89.2k
1 vote
1 answer
820 views

How to evaluate a variable as an expression for axis label in R?

Objective is to allow user to pass a string to a plotting function and have it evaluated correctly as plotmath. Question is how to combine an evaluated expression with other string text. It seems ...
Minnow's user avatar
  • 1,761
1 vote
2 answers
1k views

high-order function causes unsafe eval in chrome extension

I am making a very simple chrome extension to randomly change the wallpaper on my chromebook. But I am getting a strange error in the Javascript console after I load it: Refused to evaluate a ...
Griffin Young's user avatar
4 votes
1 answer
1k views

Google BigQuery: Using TABLE_QUERY if project_id contains a hyphen "-"

This extends Jordan's post here: How do I use the TABLE_QUERY() function in BigQuery? Here is an example of working TABLE_QUERY SQL. SELECT count(*) FROM TABLE_QUERY(publicdata:samples, "...
cgnorthcutt's user avatar
  • 3,906
1 vote
1 answer
100 views

Reference variable with computed name [duplicate]

I'm looking to access a variable by using a variable name dynamically computed at runtime. Example code: var firstSecond = ['a', 'b', 'c']; var tempDatabase = 'first'; var tempTable = 'Second'; var ...
jarsushi's user avatar
0 votes
1 answer
452 views

How do I avoid using EVAL in a Repeater with VB.NET?

I want to stop using EVAL everywhere in my code and remove it from all repeaters. The project I am working on is in .NET 3.5. I have this class Public Class person Public Name As String ...
NinjaBomb's user avatar
  • 793
1 vote
4 answers
122 views

How to evaluate a string in IF?

I've a string that contains a condition like "$a==1||$b==2||$c==3". What should I do to evaluate this string (as a condition) using IF statement?
Pramodh Kampalli's user avatar
1 vote
2 answers
41 views

Reading from file into dictionaries, and strange eval() behaviour

Creating dictionaries from file using eval(), or ast.literal_eval() (as suggested by others) yields strange results, and I'm not sure why. My file, file.txt contains this: {0 : {1: 6, 1:8}, 1 : {1:...
moomin's user avatar
  • 49
3 votes
1 answer
339 views

How to *not* expand "~" in tcsh backtick/eval wrapper?

I'm not interested in a "why tcsh is evil" response, this question requires tcsh for it's use. If this is a bug in tcsh, please just let me know that. I'm generally pretty good at quoting output but ...
David Ljung Madison Stellar's user avatar
1 vote
1 answer
242 views

How to prevent Python's eval() from using "...", when evaluating lists?

I've noticed that Python's eval() function shortens some lists, using "...": In [10]: eval ('array([1. / 5.0e-12] + [0.]*1023)') Out[10]: array([ 2.00000000e+11, 0.00000000e+00, 0.00000000e+00, ...
dbanas's user avatar
  • 1,828
0 votes
1 answer
644 views

Is it possible to evaluate a var/let with Swift?

Based upon this question: << Is the a ScriptEngine or eval()-like function in Swift? >> I'm assuming the following would not work in Swift: private let BROWN_COLOUR: UIColor = UIColor....
Joseph Beuys' Mum's user avatar
3 votes
2 answers
2k views

Is this wordpress virus?

I've just noticed that some of my wordpress projects contain some random code in a specific location. For example: wp-includes/meta.php contains in the bottom of file code below: check_meta(); ...
Marcin's user avatar
  • 1,014
1 vote
1 answer
578 views

Read in and merge many CSV files into data.table

I have many .csv files, containing variables for the same "population", keyed by surname and first.name. So every csv has three columns: first name, surname and the variable of interest. I load each ...
Konstantinos's user avatar
  • 4,246
5 votes
1 answer
2k views

Generate a custom Blockly block from a user-provided string without eval

I am converting a string into a Google Blockly block using JavaScript. The input string is something like "Hello %s World" - where %s defines a string input. I need to turn that into: ...
user2370460's user avatar
  • 7,660
2 votes
0 answers
206 views

React Native- loading app parts on demand?

My app consists of 5000+ views, and my boss wants those views to be served from the backend. So I need to create a app/shell in react native, that will be installed via app store, and that will know ...
Pavle Lekic's user avatar
  • 1,112
0 votes
2 answers
2k views

eval returning undefined, browser returning a result

I've got a javascript string such as the following: "h" + "e" + "l" + ("foo", "bar", "l") + ("abc", "def", "o") If I save the string to a variable and eval it, it returns as undefined: var str = "h"...
user avatar
0 votes
1 answer
894 views

JavaScript - pass string variable to eval

Part of code my generates a string, which is then suppose to be used by a function to generated a chuck in VoxelJS. An example string is "(y == 1)? 1 : 0" Which I then need to be added to a ...
Keith M's user avatar
  • 1,219
0 votes
2 answers
607 views

eval is not working with variable

my problem is eval with variable. I am using $.post this is so good for me. And returning $(#172161616).css("color",'blue'); or $(#172161616).css("color",'red'); this is working i can return ...
cimicimi's user avatar
  • 208
1 vote
1 answer
3k views

org-mode in Emacs: eval chunks of code in asynchronous mode

I am using org-mode to write reports including chunks of codes. When I want to generate the output (a PDF usually), org-mode executes all the commands in the file, which is fine. The problem however, ...
maroxe's user avatar
  • 2,097
1 vote
0 answers
200 views

Transferring Python globals and locals to Lua

I'm trying to write Pyton 3 wrapper for eval() function for Lua source strings. For executing Lua expressions in Python I use eval() from Lupa library. But signature of eval() in Lupa is differ from ...
VeLKerr's user avatar
  • 3,067
1 vote
4 answers
3k views

Array to string conversion not working

I am trying to print out this code in a string. var x = [[1, 2, 3, 4.5, 6], [7, 8.5, 9.5, 10]];` console.log(x.toString()); This is what shows up. When I print out the regular string, like so- ...
Ron's user avatar
  • 57
2 votes
1 answer
296 views

eval() function not working with global scope

I am using CreateJS to animate an object. I want to move the circle shape to a position that changes in a for loop. var x = { time: 200, x: 0, y: 0 }; I am going to ...
Ron's user avatar
  • 57
2 votes
2 answers
351 views

My program keeps getting an error "division by zero"

This program is designed to count an unspecified amount of integers, determines how many negative and positive values have been read, and computes the average and total of the input values. If the ...
BenjaminT's user avatar
21 votes
3 answers
1k views

eval is evil, but is it flawed? [duplicate]

If I run this: eval('{ear: {"<=": 6}}'); I get an error: Uncaught SyntaxError: Unexpected token : Let's create the object manually: var foo = {}; foo.ear = {}; foo.ear["<="] = 6; Now, ...
Lajos Arpad's user avatar
  • 70.1k
0 votes
1 answer
53 views

How best to dynamcially prepare and run user supplied Perl operators

Context: Perl script initializes itself based on a user-supplied param-file, then acts on a user-supplied source-file to filter out data and do other operations. The param-file file contains partial ...
lzc's user avatar
  • 919
0 votes
4 answers
2k views

Getting the "window" object for an eval, and list all vars? Javascript eval inline html

Eval is generally disliked, but it seems necessary. Currently, I have an ajax call that retrieves a html file that has inline javascript. Then it gets the script by tagname and evals it. This all ...
Seph Reed's user avatar
  • 9,742
0 votes
0 answers
37 views

R shiny - update UI layout using output$"variable" [duplicate]

Is it possible to reference the shiny UI by way of variable names? I.e. Say I have as list of countries and for each country I wish to create a UI table output during a loop. Instead of writing out ...
gmarais's user avatar
  • 1,881
1 vote
0 answers
918 views

handle the eval function exceptions

I'm using the eval method in my project and I have to handle all the possible exceptions it may raise. I thought that simple try and except would work but when I enter a symbol it doesn't familiar ...
Maor2871's user avatar
  • 147
0 votes
1 answer
226 views

JavaScript eval for expressions in somewhat isolated environment

I have an array of instructions that look like this: [ {"name": "a", "expr": "1"}, {"name": "b", "expr": "4"}, {"name": "c", "expr": "a * b + 100"}, {"name": "a", "expr": "a - 5"} ] I want ...
GreyCat's user avatar
  • 16.9k
0 votes
2 answers
4k views

How can I pass a variable from imacros to a javascript?

I need to multiply a value from imacros with a javascript value. I can pass the javascript value to imacros, but imacros unable to multiply it. Also, I didn't find any solution, how to extract a ...
J4r0sl4v's user avatar
1 vote
1 answer
254 views

undefined identifier, eval expression in file

How do I set things up so that I can call eval on quoted forms of procedures defined in the same file as they are evaluated? minimal example. I have the three expressions written into a file. #lang ...
beoliver's user avatar
  • 5,659
2 votes
0 answers
345 views

Bash: Tokenize string using shell rules without eval'ing it?

I'm writing a wrapper script. The original program's arguments are in a separate file, args. The script needs to split contents of args using shell parameter rules and then run the program. A partial ...
nvamelichev's user avatar
0 votes
0 answers
44 views

Sending a header that is stored as a string in a variable

I have a function that builds an HTTP header to be send the user. So: $header = build_header($param1, $param2); // the function build_header will return the header I want to send as a string, e.g.: /...
MoritzLost's user avatar
  • 2,741
0 votes
1 answer
466 views

go to the next step if {{!EXTRACT}} is true

i'm new here and newbie in imacros and javascript I have made a script that will extract a random word from a page with a regex syntax. The script is working fine, is going to page.. is search for ...
Alexandru Vorobchevici's user avatar
1 vote
2 answers
771 views

Wait for a specific time on a website to start a process

I want to launch a process at very specific time. The website has a time indicator: TAG POS=1 TYPE=FONT ATTR=TXT:2:31:35PM What I need to do is the following: If the time is 2:45:00PM , WAIT= 0....
AVL's user avatar
  • 11
1 vote
1 answer
2k views

r equivalent of matlab eval

Background: MatLab (or MATLAB) has a command called "eval". It allows text based construction of statements and their execution. this code: x = 1:100 y = sin(x*(pi/50)) f1 = 'plot(' f2 = '...
EngrStudent's user avatar
  • 1,942

1
42 43
44
45 46
99