Solved

Sahi scripting

Posted on 2010-08-24
4
484 Views
Last Modified: 2012-05-10
Adding this line: var $Array2 = getLinks();
to my code the "undefined variable" problem is gone. Now I have a different problem, with java I believe. My code:
var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
function getLinks(){
      var $retVal = new Array();
      var $links = document.links;  
      for (var $i=0; $i<$links.length; $i++){
            $retVal[$i] = $links[$i].innerHTML;  //getText or some other function?
      }                                            //links.getElementById("").innerHTML;
      return $retVal;
}
importPackage(java.util.Arrays)
var $Array2 = getLinks();
var $check = java.util.Arrays.equals($Array1, $Array2);
if($check == false)
      Packages.java.lang.System.out.println("Projects' names don't come in the right order.");
else
      Packages.java.lang.System.out.println("Projects' names come in the right order.");
This is the error message I get:
JSERROR
The choice of Java constructor equals matching JavaScript argument types (object,object) is ambiguous; candidate constructors are:
boolean equals(char[],char[])
boolean equals(java.lang.Object[],java.lang.Object[])
boolean equals(float[],float[])
boolean equals(double[],double[])
boolean equals(boolean[],boolean[])
boolean equals(byte[],byte[])
boolean equals(long[],long[])
boolean equals(int[],int[])
boolean equals(short[],short[]) at 24-Aug-2010 12:02:50
I don't know how to carry on from here. Anyone any light on this?

Ana
      
0
Comment
Question by:ana-redondo-lopez
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33509873
What a weird thing to do

Do you mean

boolean equals = Arrays.equals(arrayOne, arrayTwo);  


0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 300 total points
ID: 33509893
Why not just javascript?

var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");

function compareLinks(){

  var $links = document.links;  

  for (var $i=0; $i<$links.length; $i++){

    if ($Array1[$i]!==$links[$i].innerHTML) return false;

  }                                    

  return true;

}



if (compareLinks()) alert('They are the same');

Open in new window

0
 
LVL 3

Assisted Solution

by:gremwell
gremwell earned 200 total points
ID: 33509940
Perhaps you better off not interfacing Java to compare arrays at all. Use scripting language itself to do the task, see the example at the bottom of http://www.hunlock.com/blogs/Mastering_Javascript_Arrays web page.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33509988
Ah

I see from gremwell's link that I should also compare length

function compareLinks(){
  var $links = document.links;  
if ($links.length !=$Array1.length) return false;
  for (var $i=0; $i<$links.length; $i++){
    if ($Array1[$i]!==$links[$i].innerHTML) return false;
  }                                    
  return true;
}

no need to recourse though
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now