<?xml version="1.0"?>
<rss version="2.0">
 <channel>
  <title>Need Help with looping arrays | WPDFD.com Forums</title>
  <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/</link>
  <description>A Scripting forum thread at WPDFD.com</description>
  <language>en-us</language>
  <pubDate>04/27/05, 117 42 2005 2005:%i:1114612975 10:42:55</pubDate>
  <lastBuildDate>06/07/13, 158 58 2013 2013:%i:1370588295 02:58:15</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>NineLabs Framework Feed Generator</generator>
  <managingEditor>sitemaster@wpdfd.com</managingEditor>
  <webMaster>sitemaster@wpdfd.com</webMaster>
     <item>
    <title>Ratznjammers  said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1906</link>
    <description><![CDATA[The following code loops one time .... <br />I would like it to loop indefinitely ...<br />Can anyone help?<br /><br />&lt;head&gt;<br />&lt;title&gt;SurfBoard - Riding the Internet wave!&lt;/title&gt;<br /><br />&lt;script language=&quot;JavaScript&quot;&gt;&lt;!--<br /> &nbsp;var site = 0;<br /> &nbsp;var delay = 15;<br /> &nbsp;var num_sites = 9;<br /> &nbsp;var counter = delay;<br /><br /> &nbsp;function loadSites() {<br /> &nbsp; &nbsp;sitename = new Array(num_sites);<br /> &nbsp; &nbsp;sitename[0]=' Image 0';<br /> &nbsp; &nbsp;sitename[1]=' Image 1';<br /> &nbsp; &nbsp;sitename[2]=' Image 2';<br /> &nbsp; &nbsp;sitename[3]=' Image 3';<br /> &nbsp; &nbsp;sitename[4]=' Image 4';<br /> &nbsp; &nbsp;sitename[5]=' Image 5';<br /> &nbsp; &nbsp;sitename[6]=' Image 6';<br /> &nbsp; &nbsp;sitename[7]=' Image 7';<br /> &nbsp; &nbsp;sitename[8]=' Image 8';<br /> &nbsp; <br /> &nbsp; &nbsp;siteurl = new Array(num_sites);<br /> &nbsp; &nbsp;siteurl[0]='http://xxxxxxxxxx.com/ban/Image0.html';<br /> &nbsp; &nbsp;siteurl[1]='http://xxxxxxxxxx.com/ban/Image10.html';<br /> &nbsp; &nbsp;siteurl[2]='http://xxxxxxxxxx.com/ban/Image11.html';<br /> &nbsp; &nbsp;siteurl[3]='http://xxxxxxxxxx.com/ban/Image12.html';<br /> &nbsp; &nbsp;siteurl[4]='http://xxxxxxxxxx.com/ban/Image13.html';<br /> &nbsp; &nbsp;siteurl[5]='http://xxxxxxxxxx.com/ban/Image14.html';<br /> &nbsp; &nbsp;siteurl[6]='http://xxxxxxxxxx.com/ban/Image15.html';<br /> &nbsp; &nbsp;siteurl[7]='http://xxxxxxxxxx.com/ban/Image18.html';<br /> &nbsp; &nbsp;siteurl[8]='http://xxxxxxxxxx.com/ban/Image20.html';<br /><br /> &nbsp;}<br /><br /> &nbsp;function countDown() {<br /> &nbsp; &nbsp;if ((document.surfboard.autosurf.checked) &amp; (site != (num_sites - 1))) {<br /> &nbsp; &nbsp; &nbsp;document.surfboard.timer.value = counter-- + ' sec';<br /> &nbsp; &nbsp; &nbsp;if (counter != -1)<br /> &nbsp; &nbsp; &nbsp; &nbsp;setTimeout('countDown()',1000);<br /> &nbsp; &nbsp; &nbsp;else {<br /> &nbsp; &nbsp; &nbsp; &nbsp;forward();<br /> &nbsp; &nbsp; &nbsp; &nbsp;countDown();<br /> &nbsp; &nbsp; &nbsp;}<br /> &nbsp; &nbsp;}<br /> &nbsp;}<br /><br /> &nbsp;function displayDelay() {<br /> &nbsp; &nbsp;document.surfboard.timedelay.value = delay;<br /> &nbsp;}<br /><br /> &nbsp;function displayInfo() {<br /> &nbsp; &nbsp;document.surfboard.sitenamefield.value = sitename[site];<br /> &nbsp; &nbsp;document.surfboard.siteurlfield.value = siteurl[site];<br /> &nbsp;}<br /><br /> &nbsp;function back() {<br /> &nbsp; &nbsp;if ( site == 0 )<br /> &nbsp; &nbsp; &nbsp;alert('Already at first site!')<br /> &nbsp; &nbsp;else {<br /> &nbsp; &nbsp; &nbsp;site--;<br /> &nbsp; &nbsp; &nbsp;counter = delay;<br /> &nbsp; &nbsp; &nbsp;load(siteurl[site]);<br /> &nbsp; &nbsp; &nbsp;displayInfo();<br /> &nbsp; &nbsp;}<br /> &nbsp;}<br /><br /> &nbsp;function forward() {<br /> &nbsp; &nbsp;if ( site == (num_sites - 1) )<br /> &nbsp; &nbsp; &nbsp;alert('Last site!')<br /> &nbsp; &nbsp;else {<br /> &nbsp; &nbsp; &nbsp;site++;<br /> &nbsp; &nbsp; &nbsp;counter = delay;<br /> &nbsp; &nbsp; &nbsp;load(siteurl[site]);<br /> &nbsp; &nbsp; &nbsp;displayInfo();<br /> &nbsp; &nbsp;}<br /> &nbsp;}<br /><br /> &nbsp;function load(url) {<br /> &nbsp; &nbsp;opener.location.href= url;<br /> &nbsp;}<br /><br /> &nbsp;function makeTop() {<br /> &nbsp; &nbsp;if (document.surfboard.ontop.checked)<br /> &nbsp; &nbsp; &nbsp;self.focus();<br /> &nbsp;}<br /><br />//--&gt;&lt;/script&gt;<br />&lt;/head&gt;<br /><br />Thank You]]></description>
    <pubDate>04/27/05, 117 42 2005 2005:%i:1114612975 10:42:55</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1906</guid>
   </item>
     <item>
    <title>Joe Gillespie said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1907</link>
    <description><![CDATA[The way to do this, instead of firing off timers all over the place is simply to read the Date object and use getTime() in a recursive loop. <br /><br />Check this out...<br /><br />http://www.wpdfd.com/editorial/timer.html<br /><br />for an example of a recursive loop - refreshClock().<br /><br />With a little math, you can easily change the image based on the current second or millisecond - so, if the seconds divides exactly by 15 (use modulo operator %), for instance, you move to the next slide. Keep an incrementing index count of the slide number and<br /><br />if(index == 9) {index = 0;}<br /><br />Use the index as the array dimension...<br /><br />sitename[index]]]></description>
    <pubDate>04/27/05, 117 48 2005 2005:%i:1114624081 13:48:01</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1907</guid>
   </item>
     <item>
    <title>Ratznjammers  said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1908</link>
    <description><![CDATA[Thank you for the input, however I am unable to understand what you are talking about as I am very new to Javascript and I keep going around in circles.<br /><br />If possible can you just tell me where and what to add to the code? Or better yet just place the correction into the code.<br /><br />Thanks<br />Wayne<br />]]></description>
    <pubDate>04/27/05, 117 53 2005 2005:%i:1114628001 14:53:21</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1908</guid>
   </item>
     <item>
    <title>Joe Gillespie said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1909</link>
    <description><![CDATA[If is was a simple as that, I would, but your approach is all wrong. If you use the timer method more than a few times in succession, all those timer calls fill up memory (the stack) very quickly and the browser will crash - maybe the whole system.<br /><br />I think that you need to find a script specifically for the task or get someone to write one for you.]]></description>
    <pubDate>04/28/05, 118 53 2005 2005:%i:1114707237 12:53:57</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1909</guid>
   </item>
     <item>
    <title>David  said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1910</link>
    <description><![CDATA[If I recall correctly, Firefox doesn't allow recurrsive looping. At least, the option is available but switched off by default. Something to bear in mind.]]></description>
    <pubDate>04/29/05, 119 11 2005 2005:%i:1114791079 12:11:19</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1910</guid>
   </item>
     <item>
    <title>Ratznjammers  said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1911</link>
    <description><![CDATA[<br /><br /><br /><br /><br /> &nbsp;function forward() { <br /> &nbsp; &nbsp;if ( site == (num_sites - 1) ) [[ change this to ( site == 9 ) ????<br /> alert('Last site!') [[ change this alert to a call to site=0 ]] &nbsp;????<br /> &nbsp; &nbsp;else { <br /> site++; <br /> counter = delay; <br /> load(siteurl[site]); <br /> displayInfo(); <br /> &nbsp; &nbsp;} <br /><br />It seems like all one needs to do is <br />change this function from an alert to<br />a call to site=0<br /><br />As this code operates in Frames there<br />is no 'crash' ,,, as I have run the code <br />480 image views and ram memory usage <br />has not changed. and I doubt that the<br />stack has been overloaded, as no <br />crash has occurred.<br /><br />why would you have me re-write the whole <br />code? when only a minor change is necessary<br /><br />]]></description>
    <pubDate>04/30/05, 120 14 2005 2005:%i:1114866847 09:14:07</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1911</guid>
   </item>
     <item>
    <title>David  said:</title>
    <link>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1912</link>
    <description><![CDATA[Here's some pseudo code:<br /> &nbsp;<code><br />for(;<img src="/images/emoticons/wink.png" class="smiley" />{ &nbsp;//infinite loop<br /> &nbsp;for (i=0;i&lt;10;i++){ &nbsp;// counts up from 1 to 9<br /> &nbsp; &nbsp;load i.html;<br /> &nbsp; &nbsp;refresh_clock();<br /> &nbsp;}<br />}<br /></code><br /><br /><i>&gt;&gt; why would you have me re-write the whole &nbsp;<br />code? when only a minor change is necessary </i><br /><br />Your code is about 10 times the size of what it needs to be. Why make the computer work harder than it has to? Besides which, the less code you have, the less room there is for bugs.]]></description>
    <pubDate>04/30/05, 120 24 2005 2005:%i:1114874684 11:24:44</pubDate>
    <guid>http://www.wpdfd.com/forums/wpdfd/scripting/need_help_with_looping_arrays/#p1912</guid>
   </item>
   </channel>
</rss