Hi Everybody
I have problem with the following script
I use jsEditor95 and I get error message
"line 308 { is expected "
But it must be some other error in the script but I cant find it
IE5.5 gives error message "line 490 it is not an object"
Thankfull for advice
Attach the script as zip file only to unzip and open the html file
in a sutable browswer or editor.
Sincerely
Urban Avierfj�rd
Visby,Gotland,Sweden
ICQ#69907743
Homepage http://w1.201.telia.com/~u20100003
E-mail [EMAIL PROTECTED]
<HTML>
<HEAD>
<META NAME="KEYWORDS" CONTENT="MY FILE">
<META NAME="DESCRIPTION" CONTENT="MY FILE">
<META NAME="JAVASCRIPT GENERATOR" CONTENT="jsEditor">
<title>DynAPI Distribution: Create Example</title>
<script language="Javascript" src="src/dynapi.js"></script>
<script language="Javascript">
DynAPI.setLibraryPath('src/lib/');
DynAPI.include('dynapi.api.*');
DynAPI.include('dynapi.event.*');
DynAPI.include('dynapi.gui.dynimage.js');
</script>
<script language="Javascript">
     luff = new Array(25)// The two dimensional Array luff is created
globaly
        for (i=0; i < 25; i++) {
           luff[i] = new Array(25);
}
     var fyrairad=0;
     var femirad=0;
     var k=0;
     var l=0;
     var r=0;
     var q=0;
     var s=0;
     var p=0
     var o=0;
     var z=0;
     var a=0;
     var b=0;
     var c=500;
     var d=500;
     var A=0;
     var B =0;
     var h=0;
     var v =0;
     var dim =0;
function Calculate(){/* Here should the engine be situated that give
                                  the cordinates c and d for where the cross
should be placed on the board
                                  the code for ring is 87 ,for cross 91 and
emty square 47*/

                              /*Give the varibleo (1-25) that are the
cordinate the y direction
                              for the square lowest down att the bottom of
the board
                              that contains a cross or ring*/
  o=0;
for (i=1;i<26; i++){
        for (j=1;j<26; j++){
              if (luff[i-1][j-1]!=47){
                   if (j>o){                file://line 49
                           o=j;
}
}
}
}
     p=0;               /*give the varible p (1-25) that are the cordinate
in the x direction
                           for the square  most at right that
                           contains a  ring or cross*/
for (i=1;i<26; i++){
      for (j=1;j<26; j++){
          if (luff[j-1][i-1]!=47){
                if (j>p){
                   p=j;
}
}
}
}
                          /* give the varible q (1-25) that are the
cordinate in y direction
                            for the square most up on the board
                            that contains a ring or cross*/
       s=0;
       q=26;
for (i=1;i<26; i++){
     s=0;
     for (j=1;j<26; j++){
          if (luff[j-1][i-1]!=47){
                if (s==0){
                    s=s+1;
                      if (i<q){
                          q=i;
}
}
}
}
}
                         /* give the varible r (1-25) that are the cordinate
in x direction
                            for the square most to the left on the board
                            that contains a ring or cross*/
        s=0;
        r=26;
for (i=1;i<26; i++){
     s=0;
     for (j=1;j<26; j++){
          if (luff[j-1][i-1]!=47){
                if (s==0){
                    s=s+1;
                      if (j<r){
                         r=j;                      file://line 97
}
}
}
}
}
r=r-3;                  /*calculates new values for r,q.o and p that are the
new cordinates for the smaller Array motorluff on the board
                           that contains rings and crosses*/
if (r<1){
r=1;
}
q=q-3;
if (q<1){
q=1;
}
o=o+3;
if (o>25){
o=25;
}
p=p+3;
if (p>25){
p=25;
}
                     /*calculates the sieze dim of array motorluff */
k=o-q+1;
l=p-r+1;
if
{   
    dim = k;
}
else {
 dim = l;
}
/*Create the two dimensional Array motorluff with the sieze dim
 and shold be placed on the board at cordinates r and q*/
var motorluff =new Array(dim);
for (i=0;i<dim; i++){
motorluff[i]=new Array(dim);
}
var motordiagonal = new Array(2*dim-1);/*Creates the two dimensional Array 
motordiagonal with the sieze 2*dim-1 
                                                             that should  be used for 
testig for crosses and rings in the diagonals*/
for (i=0; i<2*dim-1;i++) {                          
   motordiagonal[i] = new Array(2*dim-1);
}
while (r+dim>26){
      r=r-1;
}
while (q+dim>26){                                         
      q=q-1
}                                                            file://line 145
          for (i=r;i<r+dim; i++){                  
             for (j=q;j<q+dim; j++){  
                motorluff[i-r][j-q]=luff[i-1][j-1];
}
}
/*The following script  take values from the two dimensional Array motorluff with the 
sieze dim and
and places them in the two dimensional Array motordiagonal with the sieze 2*dim-1 */
n=dim+1;
for (k=1;k<dim+1; k++){
n=n-1;
m=dim+1-k;
o=n;
for (l=0;l<k; l++){
motordiagonal[o-1][k-1] = motorluff[m-1][l];
m = m+1;
o=o+2
}
}   
p=dim-1;
n=1;
k=dim;
while (k>1){
k=k-1;
n=n+1;
m=dim+1-k;
p=p+1;
o=n;
for (l=0;l<k; l++){
motordiagonal[o-1][p] = motorluff[l][m-1];
m=m+1;
o=o+2;
}
}
/*The following tests for five in a row in the y direction*/
femirad=0;
for (i=0;i<dim; i++){
     p=0;
       for (j=0;j<dim; j++){
            if (motorluff[i][j]==87){
                p = p+1
                if (p==5){
                   alert("Congratulations You have get five in a row");
                   femirad=5;
}
}                                             
else {
p=0;
}                                                       file://line 193
}                                               
}
if (femirad==0){
/*the following tests for Five in a Row in the x direction*/
for (i=0;i<dim; i++){
     p
=0;
       for (j=0;j<dim; j++){
            if (motorluff[j][i]==87){
                p = p+1
                if (p==5){
                   alert("Congratulations You have get five in a row");
                   femirad=5;
}
}
else {
p=0;
}
}
}
if (femirad==0){
// The following tests for Five in a Row in one of the two diagonals
     for (i=0;i<2*dim-1; i++){
             for (j=0;j<2*dim-1; j++){
                  if (motordiagonal[i][j]==87){
                      var p=1;
                      var m=j;
                      m=m+2;
                              if (m<2*dim-2){
                                    while (motordiagonal[i][m]==87){
                                         p=p+1;
                                         m=m+2;
                                           if (p==5){
                                                 alert("Congratulations You
have get five in a row");
                                                 femirad=5;
}
}
}
}
}
}
if (femirad==0){
/* This tests fo Five in a Row in the other diagonal*/
  for (i=0;i<2*dim-1;

             for (j=0;j<2*dim-1; j++){
                  if (motordiagonal[j][i]==87){
                      var p=1;
                      var m=j;
                      m=m+2;
file://line 241
                              if

                                    while (motordiagonal[m][i]==87){
                                         p=p+1;
                                         m=m+2;
                                           if (p==5){
                                                 alert("Congratulations You
have get five in a row");
                                                 femirad=5;
}
}
}
}
}
}
if (femirad==0){     file://first if statement
file://tests for Four rings in a Row in the y direction
fyrairad=0;
for (i=0;i<dim; i++){
     p=0;
       for (j=0;j<dim; j++){
            if (motorluff[i][j]==87){
                p = p+1
                if (p==4){
                fyrairad=4;
}
}
else {
p=0;
}
}
}
if (fyrairad==0){     file://second if statement
file://tests for four rings in a row in the x direction
for (i=0;i<dim; i++){
     p=0;
       for (j=0;j<dim; j++){
            if (motorluff[j][i]==87){
                p = p+1
                if (p==4){
                fyrairad=4;
}
}
else

p=0;
}
}
}
if (fyrairad==0){           file://fourth if statement
file://tests for four in a row in one of the two diagonals
file://line 241
     for (i=0;i<2*dim-1;

             for (j=0;j<2*dim-1; j++){
                  if (motordiagonal[i][j]==87){
                      var p=1;
                      var m=j;
                      m=m+2;
                              if (m<2*dim-2){
                                    while (motordiagonal[i][m]==87){
                                         p=p+1;
                                         m=m+2;
                                           if (p==4){
                                              fyrairad=4;
}
}
}
}
}
}
if (fyrairad==0;){   file://4e if satsen
file://tests for four in a row in the other diagonal
  for (i=0;i<2*dim-1;

             for (j=0;j<2*dim-1; j++){
                  if (motordiagonal[j][i]==87){
                      var p=1;
                      var m=j;
                      m=m+2;
                              if (m<2*dim-2){
                                    while (motordiagonal[m][i]==87){
                                         p=p+1;
                                         m=m+2;
                                           if (p==4){
                                                  fyrairad=4;
}
}
}
}
}
}
if (fyrairad==0){     file://fifth if statement
/*The following calculates cordinates c and d for the cross so it places
close
  under the ring*/
for (i=1;i<dim+1; i++){
       for (j=1;j<dim+1; j++){
            if (motorluff[i-1][j-1]==87){
                   if (motorluff[i-1][j]==47){
                        c= 20*(i+r-2);
                        d= 20*(j+ q-1);
                        luff[i+r-2][j+q-1]=91;
file://line 237
}
}
}
}
}
}
}
}
}
}
function getAB(e){/*gives x and y cordinates for the mouse on the board
                              and give the values to A and B*/
        A=e.getX()
        B=e.getY()
}
function myarray(){/*The following gives cordinates for the squares on the
board
                               from one to twentyfive in x and y direction
the cordinates are called h(horizontal) and v(verticaly)
                               also teststs if the square alrady con tains a
ring or cross and if so
                               Z is set to one for not to call the function
calculate a second time
                               and if not luff[h-1][v-1] is set to the code
87 for a ring
                               myarray also calculate  cordinates a and b
for where on the board the ring should be placed on the DynLayer(the Board)
*/
                H=0;
                for (i=0;i<=480; i=i+20){
                        H=H+1
                        for (j=0;j<=20;j++){
                        if (i+j==A){
                        h=H
                        a=i
}
}
}
              V=0;
              for (k=0;k<=480;k=k+20){
              V=V+1
              for (l=0;l<=20;l++){
              if (k+l==B){
              v=V
              b=k
}
}
}
if (luff[h-1][v-1]==91){
a=500;
b=500;
z=1;
}
else if (luff[h-1][v-1]==87){
z=1;                                                       file://line 285
}
else{
 luff[h-1][v-1]=87;
}
}
 function layout() {
        for (i=0;i<25; i++){//fills up the two dimensional Array luff with
code for empty square 47
                  for (j=0;j<25; j++){
                           luff[i][j] = 47;
}
}
        myLayer = new DynLayer();
 myLayer.setSize(500,500);
 myLayer.setBgColor('purple');
 myLayer.moveTo(5,50);
                myListener = new EventListener(DynAPI.document);
  myListener.onmousemove=function(e){
   myLayer.setBgColor('pink');
}
                 myListener.onmouseout=function(e){
   myLayer.setBgColor('deeppink');
}
  myListener.onmousedown=function(e) { /* This function detects if You press
the mouse button

and then calls the functions getAB and myarray  and the

the ring is placed on the board and then the function Calculate

is called witch returns values c and d for vere the cross should be placed*/
                        getAB(e);
                        myarray();
                        myChild2 = new DynLayer(null,a,b,20,20,'violet');
                        myChild2.setHTML('<img src=Animation3.gif>');
                 myLayer.addChild(myChild2)
                        if (z==0) {
                           Calculate();
}
                        else {
                           z=0;
}
                        myChild2 = new DynLayer(null,c,d,20,20,'violet');
                        myChild2.setHTML('<img src=Animation4.gif>');
                        myLayer.addChild(myChild2)
}
         myLayer.addEventListener(myListener);
             for (i=19;i<480; i=i+20){
             myChild = new DynLayer(null,i,0,2,500,'black');
      myLayer.addChild(myChild);
}
            for (i=19;i<480; i=i+20){
            myChild = new DynLayer(null,0,i,500,2,'black');
file://line 333
     myLayer.addChild(myChild)
}
DynAPI.document.addChild(myLayer);
}
DynAPI.onLoad = function() {
layout();
}
function newgame() {
 layout();
}
</script>
</head>
<BODY>
<BODY BGCOLOR="chocolate">
<H1>Five in a Row Game ( under Construction) You start with Rings</H1>
<PRE>






























</PRE>
<FORM><INPUT TYPE="button" VALUE="New Game" onClick="newgame();"></FORM>
 <! -- line 381 -->
</BODY>
</HTML>



The Problem five in a row game.zip

Reply via email to