Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complicated array question.

Status
Not open for further replies.

wolff69

Programmer
Joined
Apr 2, 2000
Messages
2
Location
US
i want to see if this code will do what i want:<br><br>if(var eff = new action(20) //i am declaring a new array<br>eff[0]=anyvalue;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//i list all the elements of <br>&quot; &quot; &quot; &quot; &quot; &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//of the array<br>{<br>var bgpe = 4500;<br>var bpe = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>here is the problematic part i want to test every slot in the array eff.<br><br>while ((eff * bpge)&lt;130000){<br>bpge += bpe; ++eff <br>}<br>break;<br>bepea=new bpe(20)<br>&nbsp;<br>then store every computed value from eff * bpge in the variable bpe as an array so that i can use it in other functions or methods.<br><br>1)will this code do that? <br><br>2)if not what would be the proper syntax? <br><br>3)or can i even make an array from a computed variable using java script?
 
hmm. not sure what you want.<br><br>could you please be a little bit more descriptive about what the script is SUPPOSED to do?<br><br> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
No, it wouldn't work because you're not changing bpge, only multiplying it by eff.&nbsp;&nbsp;bpge*eff will change, but not bpge.&nbsp;&nbsp;I'm not sure it will do anything, but I think it would be better to use a <FONT FACE=monospace>for</font> function rather than <FONT FACE=monospace>while</font>.&nbsp;&nbsp;I think that for is a little faster, but it may not matter. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
well then i guess storing the change in (eff*bpge) as <br><br>(eff*bpge)=bpe&nbsp;&nbsp;<br><br>will work because it wil store the change of (eff*bpge) as bpe and then i can initialize bpe as a new array.
 
You need to initialize bpe as an array first:<br><FONT FACE=monospace>bpe = new Array()</font><br><br>Notice that <FONT FACE=monospace>Array()</font> is a function already given to you, at least in JavaScript 1.1 and above.&nbsp;&nbsp;There is a script already out there for an array for older browsers though.<br><br>If I were you then, I would do the following:<br><FONT FACE=monospace><br>for (i = 0; eff &lt; 13000; i++)<br>{<br>(eff<i>*bpge)=bpe<i><br>} <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top