FRDB Archives

Freethought & Rationalism Archive

The archives are read only.


Go Back   FRDB Archives > Archives > IIDB ARCHIVE: 200X-2003, PD 2007 > IIDB Philosophical Forums (PRIOR TO JUN-2003)
Welcome, Peter Kirby.
You last visited: Today at 05:55 AM

 
 
Thread Tools Search this Thread
Old 07-13-2003, 09:27 AM   #101
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Quote:
sophie: DNAunion, you musta turned off Javascript, or disabled images. The code was working only you could not see it.
DNAunion: Ah, so you didn't test your code's results under all conditions! You determined its "correctness" by induction!

(What's that old saying, "Rubber on me, glue on you,..." )
DNAunion is offline  
Old 07-13-2003, 09:32 AM   #102
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default i

yep, the i thing, i was once a fortran programmer.

The difference between PLANspeed and LANspeed, was a cut and paste job, necessarily done to rush the code out into production. I was in a hurry to see my baby do the jiggy-do.

Honestly, I am much more careful with variablenames. Sometimes I name one variable such a long name it drifts off the screen. Then I have troubles seeing the for-loop SO I have to convert the loop to a strict-while. Troubles you have when you are a professional thinker.

(added)
Actually I forgot to tell you the conditions for running the code. Including the sweat-band. These are the external conditions most programmers forget to mention. The condition which entails their programs run like an embedded external object.
sophie is offline  
Old 07-13-2003, 11:15 AM   #103
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Arrow

just so anyone can try to follow the code...

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>GREETINGs by Sophie </title>
<link type="text/css" rel="stylesheet" href="http://www.notrich.org/GREETING/greeting.css">


<script language="JavaScript1.2">

var DANCINGimages = new Array() ;
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

var RETURNcode ;
var IMAGESindex = 0 ;
var IMAGESmax = DANCINGimages.length ;

var IMAGESpreLoad = new Array() ;
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}

var DANCINGspeed = new Array() ;
DANCINGspeed[0] = 300 ; DANCINGspeed[1] = 240 ; DANCINGspeed[2] = 180 ;
DANCINGspeed[3] = 140 ; DANCINGspeed[4] = 50 ; DANCINGspeed[5] = 130 ;
DANCINGspeed[6] = 183 ; DANCINGspeed[7] = 130 ; DANCINGspeed[8] = 50 ;
DANCINGspeed[9] = 321 ; DANCINGspeed[10] = 440 ; DANCINGspeed[11] = 500 ;

var REPEATdanceMOVE = new Array() ;
REPEATdanceMOVE[0] = 6 ; REPEATdanceMOVE[1] = 3 ; REPEATdanceMOVE[2] = 5 ;
REPEATdanceMOVE[3] = 1 ; REPEATdanceMOVE[4] = 8 ; REPEATdanceMOVE[5] = 2 ;
REPEATdanceMOVE[6] = 7 ; REPEATdanceMOVE[7] = 2 ; REPEATdanceMOVE[8] = 11 ;
REPEATdanceMOVE[9] = 2 ; REPEATdanceMOVE[10] = 4 ; REPEATdanceMOVE[11] = 4 ;

var TOTALdancingIMAGES = DANCINGimages.length ;
var COUNTimagesSHOWN = TOTALdancingIMAGES ;

var ANIMATIONtreshold = DANCINGspeed.length ;
var ANIMATORindex = ANIMATIONtreshold - 1;
var HAVErepeatedTHISmoveTHESEtimes = REPEATdanceMOVE[ANIMATORindex];

function NEXTdanceSPEED(){
   if (++COUNTimagesSHOWN > TOTALdancingIMAGES )
   {
       if ( ++HAVErepeatedTHISmoveTHESEtimes > REPEATdanceMOVE[ANIMATORindex] )
       {
            COUNTimagesSHOWN = 1 ; 
            HAVErepeatedTHISmoveTHESEtimes = 0 ;
            if (++ANIMATORindex >= ANIMATIONtreshold)
                ANIMATORindex= 0 ;
       } 
   } 
 
   return (DANCINGspeed[ANIMATORindex])
}

function ANIMATEdance()
{
  if (document.images)
  {
      document.images.DANCING.src = IMAGESpreLoad[IMAGESindex].src;
  var newspeed = NEXTdanceSPEED() ;
      if (++IMAGESindex > (IMAGESmax-1)) 
          IMAGESindex=0 ;
      RETURNcode = setTimeout('ANIMATEdance()', newspeed) ;
  }
}

</script>


</head>
<body  onload="ANIMATEdance()" bgcolor=green >

<img src = "http://www.notrich.org/ANIMATION/PLAN1.jpg" border=no NAME="DANCING"> 
                                   
We Give NICE Hi U</font>



 </body>
</html>
sophie is offline  
Old 07-13-2003, 11:37 AM   #104
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Code:
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}
DNAunion: Well, that's one way to avoid the [ i ] problem!
DNAunion is offline  
Old 07-13-2003, 11:57 AM   #105
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

DNAunion: Hmmm, seems to me that the array DANCINGimages is unnecessary. Instead of:

Code:
var DANCINGimages = new Array() ;
DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

…

var IMAGESmax = DANCINGimages.length ;

var IMAGESpreLoad = new Array() ;
for (var eye = 0; eye < IMAGESmax; eye++)
{
    IMAGESpreLoad[eye] = new Image() ;
    IMAGESpreLoad[eye].src = DANCINGimages[eye] ;
}

…

var TOTALdancingIMAGES = DANCINGimages.length ;
DNAunion: Why not just:

Code:
var IMAGESpreLoad = new Array() ;
IMAGESpreLoad[0] = new Image()
IMAGESpreLoad[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ;
IMAGESpreLoad[1] = new Image()
IMAGESpreLoad[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ;

…

var IMAGESmax = IMAGESpreLoad.length ;

…

var TOTALdancingIMAGES = IMAGESpreLoad.length ;
DNAunion: That combines two arrays into one.
DNAunion is offline  
Old 07-13-2003, 12:12 PM   #106
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default suggestion

I used the original because whenever I add or subtract an image I only need to cut and paste one line, change one index and change one file name.

With your suggestion, I have to cut and paste two lines, change two indicies, and change one file name. This case I have more possibilities for errors when I am maintaining the code. I usually mostly maintain code when I am half asleep, so I am prone to creating multiple errors.

Now think of this, at the expense of a lowly array, if during the life cycle of this code, which I expect to run two years, I regularily increase my animations, to make it more image complex, I would have wasted over 1000 cut and pastes, and would have changed an extra index 1000 times. Instead as that time accumulates, I can use the time more constructively. Memory is inexpensive these days and most people have 64Mbytes in their machines, so I feel well justified saving myself some maintanence time...
sophie is offline  
Old 07-13-2003, 06:30 PM   #107
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

DNAunion: Oh, I just debugged more of my own code. Again, it is IMPOSSIBLE for me to correct the code due to the 120-minute window for editing imposed by this forum. If I could do so, I would just fix it and wouldn't even bother bringing it up.

I thought I had better spend a few minutes to review the code I have posted here and in doing so spotted an oversight in the doubly linked list. When a Node is popped off of the stack, the Next pointer of what is then the last node is left pointing to the Node that was just deleted. A simple single line that sets that pointer to 0 corrects this.
DNAunion is offline  
Old 07-13-2003, 06:42 PM   #108
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

Quote:
Sophie: I used the original because whenever I add or subtract an image I only need to cut and paste one line, change one index and change one file name.

With your suggestion, I have to cut and paste two lines, change two indicies, and change one file name.
DNAunion: Let’s start off by listing a more-correct difference. Using the type of programming environments real programming languages provide:

Two arrays (Sophie’s original):
1) Use mouse to highlight selection
2) Right-click selection to bring up the context menu
3) Choose COPY
4) Position mouse pointer where text is to be pasted
5) Right-click to bring up context menu
6) Choose paste
7) Move to end of line where file name is: edit file name
8) Move to middle of line where index is: edit index

One array (my inquired about change):
1) Use mouse to highlight selection
2) Right-click selection to bring up the context menu
3) Choose COPY
4) Position mouse pointer where text is to be pasted
5) Right-click to bring up context menu
6) Choose paste
7) Move to end of line where file name is: edit file name
8) Move to middle of line where index is: edit index
9) Click up arrow to get to other index: edit index

The only difference is editing the extra index (that is, contrary to your statements, you wouldn’t have to do any extra work to copy and paste two lines instead of one). And, you would already be editing the other index that is immediately below it: up arrow gets you right there.

Quote:
Sophie: This case [with just one array] I have more possibilities for errors when I am maintaining the code. I usually mostly maintain code when I am half asleep, so I am prone to creating multiple errors.
DNAunion: Please. You are already editing an index and the second one is immediately above it. If we can’t trust you to remember to change the second one when you are already changing the first one, how can we trust you to remember to change the file name? How can we trust you to remember to change the first index? If you are that tired, perhaps you should wait until you wake up to edit your code!

Quote:
Sophie: Now think of this, at the expense of a lowly array, if during the life cycle of this code, which I expect to run two years, I regularily increase my animations, to make it more image complex, I would have wasted over 1000 cut and pastes, and would have changed an extra index 1000 times.
DNAunion: Hold on…you mean your rudimentary script wasn’t created just to show us that you can write code? It seemed so trivial that’s what I thought it was for. I had no idea it was going to become the Web’s next animation megaplex!

Secondly, no, you wouldn’t have wasted 1,000 cuts and pastes: in fact, you wouldn’t have wasted any. It takes just as many operations to copy and paste two contiguous lines of code as one. So that part is dismissed.

By the way, why would you CUT, and then paste? That wouldn’t get you anywhere!

Now, hypothetically, over the span of two years, assuming you add 1,000 more images to your “animation megaplex!”, then you would have to change an extra index 1,000 times. Let’s see, at about, oh 3/10 of a second per extra index, that comes out to be roughly 300 seconds “wasted” spread out over two years. If you are really worried about “wasting” 5 minutes over a 2-year span, perhaps you’re a bit too obsessed with time management.

Quote:
Sophie: Instead as that time accumulates, I can use the time more constructively.
DNAunion: Yeah, if you save it all up over 2 years, you could eventually splurge and instead of just lathering and rinsing, you could lather, rinse, and repeat!

Quote:
Sophie: Memory is inexpensive these days and most people have 64Mbytes in their machines, so I feel well justified saving myself some maintanence time...
DNAunion: Well, at least you agree that a programmer can “waste” some memory and CPU cycles if he/she feels the tradeoff is worth it.

Just so that we are straight...no matter how many tens, dozens, hundreds, or thousands of images you have, my inquired about method would be faster, require less memory, and promote code clarity.

Because I reject most of your "melodramatics", the only real downside I see – assuming you really are headed towards the amazing animation megaplex! – is that my inquired about method would bloat the source code more than yours would because it includes a separate arrayName[x] = new Image(); statement for each image. But I had no idea that your script was that switches between two images was meant for anything other than a "see, I can write some code too".

I have more to say about your code, but I'll save that for another post.
DNAunion is offline  
Old 07-13-2003, 07:10 PM   #109
Veteran Member
 
Join Date: Jan 2001
Location: USA
Posts: 1,072
Default

DNAunion: You have another unneeded variable in your code.

Both IMAGESmax and TOTALdancingIMAGES are assigned the same value, neither variable’s value is modified after being assigned, and both variables are used to test for the same type of condition.

Here are all references to those two variables:

IMAGESmax
var IMAGESmax = DANCINGimages.length ;
for (var eye = 0; eye < IMAGESmax; eye++)
if (++IMAGESindex > (IMAGESmax-1))

TOTALdancingIMAGES
var TOTALdancingIMAGES = DANCINGimages.length ;
var COUNTimagesSHOWN = TOTALdancingIMAGES ;
if (++COUNTimagesSHOWN > TOTALdancingIMAGES )

Only one of those two variables is needed.
DNAunion is offline  
Old 07-14-2003, 05:47 AM   #110
Veteran Member
 
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
Default

Only one of those two variables iis needed.
(1) IMAGESmax
(2) TOTALdancingIMAGES

True. One came before the other as if they were independently programmed. The two parts can act independently meaning a change in one part will not affect the other. This would be meaningless to you as such I concede the point.

One unnecessary variable conceded.
sophie is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -8. The time now is 07:54 PM.

Top

This custom BB emulates vBulletin® Version 3.8.2
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.