Connecting Tech Pros Worldwide Help | Site Map

how to use eval?

  #1  
Old July 23rd, 2005, 08:52 PM
Andy LW
Guest
 
Posts: n/a
var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21
elms...];
var snv = new Array();

var vals = new Array();
for (i = 0; i < N; i++) {
for (j = 0; j < fns.length; j++)
vals[j] = some value;
snv[i] = new makeData(vals);
}

function makeData(vals) {
for (k = 0; k < vals.length; k++)
//the following line doesn't work
eval("this."+fns[k]+"="+vals[k]);
//neither this one
this.eval(fns[k]) = vals[k]);
}

how can i make it without writing it the long way:

this.orde = vals[0];
this.no = vals[1];
this.kml = vals[2];

and so on?


  #2  
Old July 23rd, 2005, 08:52 PM
Lee
Guest
 
Posts: n/a

re: how to use eval?


Andy LW said:[color=blue]
>
>var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21
>elms...];
>var snv = new Array();
>
>var vals = new Array();
>for (i = 0; i < N; i++) {
> for (j = 0; j < fns.length; j++)
> vals[j] = some value;
> snv[i] = new makeData(vals);
>}
>
>function makeData(vals) {
> for (k = 0; k < vals.length; k++)
>//the following line doesn't work
> eval("this."+fns[k]+"="+vals[k]);
>//neither this one
> this.eval(fns[k]) = vals[k]);
>}
>
>how can i make it without writing it the long way:
>
>this.orde = vals[0];
>this.no = vals[1];
>this.kml = vals[2];[/color]

this[fns[k]] = vals[k];

But that seems like an odd thing to want to do.

  #3  
Old July 23rd, 2005, 08:52 PM
Andy LW
Guest
 
Posts: n/a

re: how to use eval?




--
Neither by ship nor on foot could you find the marvellous road to the
meeting-place of the Hyperboreans.
pindar, pythian odes, 10.



"Lee" <REM0VElbspamtrap@cox.net>, haber iletisinde şunları
yazdı:d6dmqf02olb@drn.newsguy.com...[color=blue]
> Andy LW said:[color=green]
>>
>>var fns = ['orde', 'no', 'kml', 'snf', 'td', 'ty', 'tn', ...up to 21
>>elms...];
>>var snv = new Array();
>>
>>var vals = new Array();
>>for (i = 0; i < N; i++) {
>> for (j = 0; j < fns.length; j++)
>> vals[j] = some value;
>> snv[i] = new makeData(vals);
>>}
>>
>>function makeData(vals) {
>> for (k = 0; k < vals.length; k++)
>>//the following line doesn't work
>> eval("this."+fns[k]+"="+vals[k]);
>>//neither this one
>> this.eval(fns[k]) = vals[k]);
>>}
>>
>>how can i make it without writing it the long way:
>>
>>this.orde = vals[0];
>>this.no = vals[1];
>>this.kml = vals[2];[/color]
>
> this[fns[k]] = vals[k];
>
> But that seems like an odd thing to want to do.
>[/color]

it works. thank you.



  #4  
Old July 23rd, 2005, 08:53 PM
David Dorward
Guest
 
Posts: n/a

re: how to use eval?


Andy LW wrote:
[color=blue]
>
>[/color]

Please don't put your sig at the top of your message, most good newsreader
and email software automatically trims it, so the entire content of your
message is lost! You might find it useful to install OE Quote Fix.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
  #5  
Old July 23rd, 2005, 08:53 PM
Andy LW
Guest
 
Posts: n/a

re: how to use eval?



"David Dorward" <dorward@yahoo.com>, haber iletisinde sunlari
yazdi:d6ep56$mrc$2$830fa17d@news.demon.co.uk...[color=blue]
> Andy LW wrote:
>[color=green]
>>
>>[/color]
>
> Please don't put your sig at the top of your message, most good newsreader
> and email software automatically trims it, so the entire content of your
> message is lost! You might find it useful to install OE Quote Fix.
>
> --
> David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
> Home is where the ~/.bashrc is[/color]

i usually delete it (as i did in my first message), but that i forgot.


  #6  
Old July 23rd, 2005, 08:53 PM
Stewart Gordon
Guest
 
Posts: n/a

re: how to use eval?


David Dorward wrote:[color=blue]
> Andy LW wrote:
>
>[color=green]
>>[/color]
>
> Please don't put your sig at the top of your message, most good newsreader
> and email software automatically trims it, so the entire content of your
> message is lost! You might find it useful to install OE Quote Fix.[/color]

You've got me wondering how he's managed to get OE to preserve the ' '
of '-- ' without OEQF.

Stewart.

--
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
  #7  
Old July 23rd, 2005, 08:54 PM
Dr John Stockton
Guest
 
Posts: n/a

re: how to use eval?


JRS: In article <d6ep56$mrc$2$830fa17d@news.demon.co.uk>, dated Wed, 18
May 2005 07:56:16, seen in news:comp.lang.javascript, David Dorward
<dorward@yahoo.com> posted :[color=blue]
>Andy LW wrote:[color=green]
>>[/color]
>
>Please don't put your sig at the top of your message, most good newsreader
>and email software automatically trims it, so the entire content of your
>message is lost! You might find it useful to install OE Quote Fix.[/color]

But *good* software will only trim it from replies (*really* good
software would IMHO leave it present but greyed and copyable but not
editable, and would remove the greyed lines at the point of transmission
as news/mail).

To trim it from the version presented for reading would be ludicrous.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
  #8  
Old July 23rd, 2005, 08:59 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

re: how to use eval?


Stewart Gordon schrieb:
[color=blue]
> David Dorward wrote:[color=green]
> > Please don't put your sig at the top of your message, most good
> > newsreader and email software automatically trims it, so the
> > entire content of your message is lost! You might find it useful
> > to install OE Quote Fix.[/color]
>
> You've got me wondering how he's managed to get OE to preserve the
> ' ' of '-- ' without OEQF.[/color]

No Content-Type heade, no character declaration or
`Content-Type: ...; charset=us-ascii' will "allow"
this in OE.


PointedEars
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ Topic - When should I use eval? FAQ server answers 8 May 20th, 2007 11:45 PM
how to use Eval with mailto? Arvan answers 2 May 25th, 2006 04:45 AM
How to use Eval or Bind with 2 values Donald Adams answers 1 May 22nd, 2006 06:35 AM
How to use - Eval("SomeItem") in a code-behind Paul answers 0 March 16th, 2006 10:35 PM