eval

how to create and assign a value to a variable created dynamically?

对着背影说爱祢 提交于 2019-12-12 07:23:13
问题 I'm trying to get this to work: function whatever(arg) { eval(arg) + '_group' = []; } The purpose is to have only 1 function instead having three with basically the same content but with different variable names. At the end I want to have something like: a_group = []; b_group = []; Doing this way, I'm getting the error: ReferenceError: Invalid left-hand side in assignment EDIT Here is the original function that I'm trying to make work. But it won't work. function collect_all_values_for(field

Using eval in make file

回眸只為那壹抹淺笑 提交于 2019-12-12 06:46:50
问题 I run a buildroot make and during this build process a text file is created. After this happens another make as part of the build is run. I want to read the contents of the generated file into a variable and use them. This doesn't work as at the start of my buildroot make it sees the file as not existing, so even though it is generated before the code is run make has already decided it doesn't exist. Format of the file read: str1 str2 1.1.0_nightlybuild (1389:1497M@trunk) I am trying to use

using a href to call javascript function with parameter

允我心安 提交于 2019-12-12 06:38:35
问题 I'm trying to call javascript function from a href . the function has a parameter which will be retrieved by the eval function . But some error occurs . script: function rate(id) { // do something } the a tag that will call the function: <a href="javascript:rate(" + <%#Eval("ID")%> + ")" >rate</a> What am I missing ? 回答1: You shouldn't be doing it like this, but the issue you're currently up against is probably is your quoting/concatenating. If <%#Eval("ID")%> simply produces an INT, this

eval returning undefined, browser returning a result

守給你的承諾、 提交于 2019-12-12 05:19:02
问题 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" + "e" + "l" + ("foo", "bar", "l") + ("abc", "def", "o"); var x = eval (str); console.log(x) // undefined However, if I paste the string into the Chrome JS console, it returns as expected: "hello" Any reason why eval would return undefined, and how is the JS console accomplishing the feat? Thanks!

error message evaluation system with PHP eval()

♀尐吖头ヾ 提交于 2019-12-12 04:26:31
问题 I'm trying out a error message evaluation system but I havn't been able to get it to work to acctually be able to evaluate the system. Can you see what is wrong with it? $errors = array(); $name = '9'; $familyname = 'family'; $user = '9user`'; $postdata = array('name' => $name,'familyname' => $familyname,'user' => $user); foreach($postdata as $key => $value) { switch($key) { case 'name': $rules = array ( 'strlen($value)>1;' => 'Your name is too short.', 'is_numeric(substr($value,0,1));' =>

Eval Calculation-string: “2 * 3 + 4 * 5” in Postgresql

喜欢而已 提交于 2019-12-12 04:25:50
问题 I would like to evaluate a pure-calculation string in Postgres. For example: eval('234 + 65 * 3') The function is NOT constant, so could also simply be 2 + 2 Expecting something like SELECT eval('2 + 2') AS result I read about huge security issues regarding eval() functions, but those seem to incorporate SELECT statements. Here pure calculation requirements. 回答1: You need PL/pgSQL : create or replace function f(_s text) returns numeric as $$ declare i numeric; begin execute format('select %s'

Why am I recieving the error 'document.write can be a form of eval'?

↘锁芯ラ 提交于 2019-12-12 04:08:53
问题 This is all I've got going, but my debugger says 'document.write can be a form of eval,' and my jsonString variable prints as undefined. Any help is appreciated, thanks. function getUrlVars() { var map = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { map[key] = value; }); return map; } var jsonString = getUrlVars()['json']; document.write(jsonString); 回答1: The reason document.write can be a form of eval is because if you write a script element

php problem with function and eval on array

99封情书 提交于 2019-12-12 04:01:28
问题 I have function: function selects($sql,$tmpl) { preg_match_all('/{[^}]*}/', $tmpl, $m); foreach($m[0] as $key => $val) { $find[] = $val; $replace[] = '$row[\''.str_replace(array('{','}'),"",$val).'\']'; } eval($replace); while($row = mysql_fetch_array($sql)) { $selects .= str_replace($find, $replace, $tmpl)."\n"; } return $selects; } echo selects($country_sql,'<option value="{id}">{name}</option>'); It outputs: <option value="$row['id']">$row['name']</option> It should output: <option value=

How to eval an attribute as string which is a custom function using Angular 1.5 component?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 03:36:20
问题 I'm using Angular 1.5. I created a menu which is a component. The menu component accept as attribute a list of jsonObject to create each menuitem. <comp-menu items="menuitems" ></comp-menu> A menuitem is a component as well. I would like to add an attribute like "action" which would be a custom function as an evaluated string in data-ng-click... of this kind : <comp-menuitem data-ng-repeat="item in items" data-ng-click="eval({{item.action}})"></comp-menuitem> The data can be like in my

eval() with a variable operator

社会主义新天地 提交于 2019-12-12 03:23:23
问题 I'm Using Python 3.4. I receive the error: Traceback (most recent call last): File "H:/GCSE's/Computing/Assesment/1/School Grading Script.py", line 44, in <module> if answer== eval(num1<currentop>num2): TypeError: unorderable types: int() < str() when trying to execute this code operator=["+","-","*"] num1=random.randint(0,10) num2=random.randint(0,10) currentop=random.choice(operator) answer = input("What is " + str(num1) + str(currentop) + str(num2) + "?\n") if answer== eval(num1<currentop