how to use eval? 
July 23rd, 2005, 08:52 PM
| | | |
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? | 
July 23rd, 2005, 08:52 PM
| | | | 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. | 
July 23rd, 2005, 08:52 PM
| | | | 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. | 
July 23rd, 2005, 08:53 PM
| | | | 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 | 
July 23rd, 2005, 08:53 PM
| | | | 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. | 
July 23rd, 2005, 08:53 PM
| | | | 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. | 
July 23rd, 2005, 08:54 PM
| | | | 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. | 
July 23rd, 2005, 08:59 PM
| | | | 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 |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|