Solved

Sahi scripting

Posted on 2010-08-24
4
491 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

695 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