473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get rid of 'eval'

This is a question to those who mean 'eval is evil'. I'm one of those.
However, I cannot answer my question. ;-)

Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

Oct 6 '08 #1
5 1568
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?
eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path

--
Stanimir
Oct 6 '08 #2
Stanimir Stamenkov wrote:
Mon, 6 Oct 2008 08:57:06 -0700 (PDT), /Proper/:
>Have a look at this page

http://home.arcor.de/pil/show-gallery.html?p=clouds

You'll notice that a parameter is passed through the URL. This is
necessary to choose the appropriate picture category. Therefore there
are three or four 'eval' inside the script.

The question is: How can this be done without 'eval'?

eval('pics.'+ category +'.length') == pics[category].length

eval('pics.'+ category +'[nr].path') == pics[category][nr].path
Right.

The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
http://jibbering.com/faq/#eval

Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Oct 7 '08 #3
On Oct 7, 4:36 am, dhtml wrote:
<snip>
The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Oct 7 '08 #4
In comp.lang.javas cript message <c3023857-d4bc-4b35-868c-39b544845219@f7
7g2000hsf.googl egroups.com>, Tue, 7 Oct 2008 02:46:43, Henry
<rc*******@rain drop.co.ukposte d:
>On Oct 7, 4:36 am, dhtml wrote:
<snip>
>The question is also answered in the FAQ:
http://jibbering.com/faq/#propertyAccess
<snup ^^^^^^^^^^^^^^^

These fragment identifiers are non-functional in IE 6. As IE 6 is
still in common use you should either correct them so that they are
functional or abandon using them.
Would http://jibbering.com/faq/index.html#propertyAccess be
functional in IE6 etc.?; memory suggests yes.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.

Usenet News services are currently unreliable; I may not see all articles here.
Oct 7 '08 #5
On Oct 7, 5:36 am, dhtml <dhtmlkitc...@g mail.comwrote:
Also see:
http://www.jibbering.com/faq/faq_not..._brackets.html
Thanks guys, especially for this article
:-)

I'll leave my example from above untouched as an example for 'evil
eval'.
Oct 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4100
by: Reply Via Newsgroup | last post by:
This might sound sad... someone requesting a disertation on the 'eval' statement... but... I've been reading someone else's post - they had a huge calander like script and a handful of folk cursed the script and special attention was thrown at the fact the script used eval alot. I don't use eval alot in my scripts - but I do use it - and...
11
1867
by: sneill | last post by:
I have read a number of posts on the use of eval() in Javascript, and I agree that its use is questionable. But it does beg the following question: "How arbitrary does a string need to be before the use of eval() is required to execute it?" Given the following code, I'm able to evaluate/execute most expressions like: "a.b.c.d()"
0
3809
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name REPORTTO. Description: An unhandled exception occurred during the execution of the
18
3147
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My question is what happens to the dynamically created assembly when the method is done running? Does GC take care of it? Or is it stuck in RAM until the...
15
3650
by: manstey | last post by:
Hi, I have a text file called a.txt: # comments I read it using this:
3
1902
by: Pauljh | last post by:
Hi All, I'm running some javascript over a server side generated web page and have multiple generated empty select statements, that I want to populate when the page is loaded. As HTML doesn't do arrays each select is individually named withe MySelecti where i is an incremental from 1. I know all my variables are correct (i, OptionsCount)...
4
2769
by: Jm lists | last post by:
Hello members, I want to know does the "eval" in python have the same features as in Perl (capture errors)? For example,in perl I can wrote: $re = eval { 1 / 0 }; Though 1/0 is a fatal error but since it's in "eval" block so the perl
6
5899
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I...
5
6625
by: wendallsan | last post by:
Hi all, I'm running into a situation where it seems that JS stops executing as soon as I call an eval in my script. I have an Ajax.Request call to a PHP page that builds a JS object and returns it as the responseText. I want to attach that object to the document (or anywhere else that would allow me to access it later), and to do that, I...
10
494
by: Gordon | last post by:
I have a script that creates new objects based on the value of a form field. Basically, the code looks like this. eval ('new ' + objType.value + '(val1, val2, val3'); objType is a select with the different types of objects you can create as values. I really don't like using eval, and it's causing problems, like if I do something like...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.