Find N max elements in unsorted array

Hi guys,
I want to find N max elements in unsorted array of integers in most efficient way as possible.
I could sort and then find the max elements but there should be some way of optimising the performance.
Any Ideas would be very much appreciated.
Cheers
J

beginerjava wrote:
I want to find N max elements in unsorted array of integers in most efficient way as possible. One idea is to keep the N largest items so far in a separate data structure. Say it's called NMAX_SOFAR. You need to keep track on the smallest item of NMAX_SOFAR. One way to accomplish this is to keep NMAX_SOFAR in sorted order. The leftmost item is then always the smallest.
When the algoritm is started NMAX_SOFAR is filled with the N first items of the array. Then the remaining elements are visited one by one. For each item it's checked whether it's larger than the smallest item of NMAX_SOFAR. If it is, it's inserted into NMAX_SOFAR and the smallest item is removed. A new larger item becomes the smallest of NMAX_SOFAR. When all items in the array have been checked, NMAX_SOFAR holds the N largest items.

Similar Messages

  • I need sorting VI that returns the sorted array element's positions in the unsorted array

    I need a VI that will very quickly (n log n) sort a 1D array of doubles.  This VI should not only output the sorted array, but for each of the sorted array elements, it should also output that sorted array element's position in the unsorted array.  So for example if the input array were:
    unsorted_array
    4.1
    2.3
    7.0
    5.6
    10.2
    Then the output arrays would be:
    sorted_array
    2.3
    4.1
    5.6
    7.0
    10.2
    indices_array
    1 (the value 2.3 is located at position 1 in the unsorted_array)
    0 (the value 4.1 is located at position 0 in the unsorted_array)
    3 (the value 5.6 is located at position 3 in the unsorted_array)
    2 (the value 7.0 is located at position 2 in the unsorted_array)
    4 (the value 10.2 is located at position 4 in the unsorted_array)
    This way I could generate the sorted_array using just the indices_array and the unsorted_array.  Has anyone written a nifty piece of code to do this?  I did some research on (n log n) sorting algorithms but most of them use recursion which I don't know how to do in LabVIEW.  It would also be nice to have an algorithm like this that could sort an array of strings.
    cheers,
    Richard

    Try something like the attached example (LabVIEW 7.0). I think it does what you need.
    (To understand the code, it is important to know that arrays of clusters are sorted by the first element in the cluster).
    Sort array itself sorts also array of strings, so you could just substitute, keeping the rest of the code the same.
    Sort array uses a variation of quicksort, so it should have about NlogN complexity.
    (If you think you only need the array of indices to later generate the sorted array, it does not make much sense to even do it. To get the indices, you need to sort the array anyway. You should just sort the plain array directly.
    Message Edited by altenbach on 07-13-2005 03:47 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortAndIndex.vi ‏26 KB

  • How to find the elements of an array

    I want to find the number of elements in an array, and I can't find the tutorial that shows how to find it. If anyone could point me in the right direction, it would be greatly appreciated.

    warnerja wrote:
    flounder wrote:
    DrLaszloJamf wrote:
    You mean x.length?<pbs>
    Depends upon your interpretation of "number of elements in the array"
    int[] numbers = new int[10];
    numbers[0] = 42;
    numbers[1] = 666;Number of elements in the array is 2 not 10.
    </pbs>If you used something other than a primitive type for the array element type you could have a case. A value of integer zero for the other elements is still a value, so there are indeed 10 elements there.Even if it were not primitive, every element would have a value. That value would either be null or a reference.

  • How to find the defference between elements in an array

    hi guys,
    this is probs an easy one for you but how can you find the diffence between all elements in an array?
    e.g array = 1 2 3 4 5 6
    so difference between 1 and two is 1, difference between 1 and 3 is 2. all the way to trough to the differece between 6 and x is x etc.
    i have been trying to use shift registers but cant quite get it.
    Thanks
    Message Edited by adamkse on 09-02-2009 01:18 AM
    Solved!
    Go to Solution.

    or maybe this:
    Harold Timmis
    [email protected]
    Orlando,Fl
    *Kudos always welcome
    Attachments:
    buildarraysubtract.JPG ‏58 KB

  • Can;t find what is wrong. Trying to add elements in two arrays

    Hello everyone
    I'm trying to take as input two numbers, convert them to arrays and add all the element of the array one by one. I want the result to be the sum of every element of the array. Let's say array1={1,2,3,4} and array2={2,6,4,3} I want the final result to be 3877.
    If the sum of one element of the array is greater than nine, then I would put zero and add 1 to the element on the left.
    Here is the code:
    import javax.swing.JOptionPane;
    public class Main {
        public static void main(String[] args) {
            String numberOne = JOptionPane.showInputDialog
                                    ("Enter the first number: ");
         String numberTwo = JOptionPane.showInputDialog
                                    ("Enter the second number: ");
            //compare string length and make them equal length
            int[]n1 = toArray(numberOne); // my first array
         int[]n2 = toArray(numberTwo); // my second array
         //call the method that ads both strings
         int[]finalArray = arrSum(n1,n2);
           JOptionPane.showMessageDialog(null, "The sum of the two numbers is: "
                   + finalArray);
        }//end of main
        //method to create an array from a string
        public static int[] toArray(String str)
                int[]arr = new int[str.length()];
                arr[0]=0;
                for (int i=1; i<str.length(); i++)
              arr= Character.digit(str.charAt(i),10);
    return arr;
    }//end of toArray
    //method to add arrays by elements
    public static int[]arrSum (int[]arr1, int[]arr2){
    for (int i = arr1.length-1; i >=1; i--)
    int sum = arr1[i] + arr2[i];
    if (sum > 9)
              { sum -= 10;
              arr1[i-1]++;
    return arr1;
    }//end of arrSum method
    }Edited by: designbc01 on Feb 16, 2010 1:15 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The best advice I can give you is to break your problem up into smaller pieces. First, focus on a method that converts an input String into an array. When you have that working perfectly, then focus on creating a method that "adds" two arrays with the logic you described. When you have that working perfectly, then combine the two different pieces.
    Why does your for loop in toArray( ) start with 1? The first index of a String, array, or pretty much anything else, is zero.

  • How can I change all Inf elements in an array to a specific value?

    I would like to change all Inf elements in my array to -1. Basically, I am looking for something similar to the range and coerce function, except that I want all values above a certain value to be a specific negative value, rather than go to that value.
    I could use a case structure and go through each element in the array, but I am hoping to find something more efficient.Any ideas?
    Solved!
    Go to Solution.

    P@Anand wrote:
    I would do that in this way.
    Here's a simpler version...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Replace in Array.png ‏4 KB

  • How many elements in an array?

    Sounds like a simple question, right?
    Apparently not.
    LV 2010
    I have a huge data structure, stored in DataLog files (thousands of them).
    I want to convert this structure to Name/Value pairs ("Operator_Name", "Joe Smith"), for use in a TDMS file.
    The structure is a cluster, with various clusters inside that, and inside those are DBLs, strings, BOOLs, other clusters, arrays, you name it.
    My strategy is to obtain the CONTROLS[ ] property of the outermost cluster and call this VI.
    The VI processes each control, decoding what type it is and handling it accordingly.
    It works fine for STRINGs, NUMERICs, ENUMs, BOOLEANs, COMBOBOXes, TIMESTAMPS, and CLUSTERs.
    For those simple ones, I use the LABEL.TEXT as the NAME and get the value (based on what type it is) as the VALUE.
    For a CLUSTER, I get the CONTROLS[ ] array of the cluster and call myself recursively, to handle all the elements within the sub-cluster.
    That all works fine.
    But to handle an ARRAY, I'm stumped.
    Attached is the code showing the case for an ARRAY.
    What I'm doing is getting the CLASS NAME of the current control.
    I LEGALIZE the label name (turn spaces into underscores, and maybe other special handling later).
    For an ARRAY, I cast the generic CTL reference into an ARRAY reference, and get its VALUE.
    I want to loop over each element of the array, and modify the name by the index number, and process each element.
    There are arrays of STRINGS, arrays of DBLs, arrays of CLUSTERs - all types.
    The question is - how many array elements are there?
    The constant "10" in this diagram is a dummy - just there to see if it works.
    it does work, except that I get 10 sets of answers, whether the real array has 2 or 20 elements.
    I thought the array's VALUE would be an ARRAY of VARIANTs, but no - it's a single VARIANT.
    I can't use VARIANT to DATA on the array's VALUE - I don't know what TYPE the array is.
    I thought maybe the ARRELEM refnum would be NIL if I was past the end, but that's not the case - there's only one refnum for any array element, whether it exists or not.
    If I check for errors, it complains that I cannot set the INDEXVALS property of a strict typedef array, even though it works just fine.
    If there was a method to SELECT ALL on the array, I could use the SELECTION SIZE to figure out how many elements there are, but I see no such method.
    The NUMBER OF ROWS / COLUMNS refers to the number of VISIBLE rows/columns, and has nothing to do with how much data is present.
    So... How do I find out how many elements are in the array?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

    The ArrElem reference property is not a reference to any particular element of the array. 
    On the contrary, it is a reference to the element addressed by the current ARRAY INDEX(es).
    That's why my code above can read out the values for element 0, element 1, etc.  I've verified that this works.
    There is only one set of PROPERTIES for the array elements; if you use the ArrElem refnum to set a background color of blue, then ALL elements turn blue, but you can obtain the VALUE of a given element by setting the ARRAY INDEX(es) and accessing via the ArrElem.
    I was thinking that maybe LabVIEW did a trick by setting this to NIL to indicate "no such element", but that's not the case.
    In any case, the question remains: How do I determine how many elements there are?
    The VALUE of the array is a variant: just what is in that package?
    As I said, I don't see how to use VARIANT TO DATA; I don't know what kind of data it is.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Number of elements in an array

    Hi,
    I have been trying looking for a simple function to get number of elements is an array. Have gone though older posts but could not find answer to it.
    The function should work for following examples:
    char* name = "nInstruments"
    float state[] = {1.0, 2.0}
    I tried sizeof but it returns size of "type" in bytes. For example in example 2, it will just return 4.
    Does someone know a way to do it?
    Ciao
    RB
    Solved!
    Go to Solution.

    RB,
    In C, if an array is declared on the heap, as opposed to on the stack as in your example above, the sizeof operator only returns the length of the pointer that holds the array which, in a 32-bit program, is always 4 bytes. This is because the compiler has no way of knowing how many elements that array actually holds. The length of a C array is a fairly fluid concept. The real size of the array is usually determined by some memory manager somewhere (usually, malloc), but it's not something that the language itself has anything to say about.
    When you declare the entire array as a local variable, however, the compiler must create room for the full array on the stack, and therefore it is able to return the true size of the array via the sizeof operator. (The same is true if it's a global variable, even if it's not on the stack, in that case)
    For this reason, using the sizeof(array) / sizeof(array[0]) trick is iffy. It might work, or it might not work, depending on how the array is declared.
    For this reason, most C APIs that accept or return arrays, will usually also have some method of communicating the length of the array, usually as an additional parameter of some function. Because .NET APIs usually have no need to do this, the C wrapper for a .NET API in CVI does this for you when it handles .NET arrays. For example, here's what a function signature might look like:
    int CVIFUNC Namespace1_Class1_Test1DArrays (Namespace1_Class1 __instance, int * inA, int __inALength, char *** outA, int * __outALength, Namespace1_Class2 ** refA, int * __refALength, double ** __returnValue, int * ____returnValueLength, CDotNetHandle * __exception);
    Luis

  • Updating elements in my array

    Hello
    Im very new to Labview and this may seem like a trivial problem to some. But it is driving me crazy. I have an array that i want to display as a table. I want to be able to input into this table and be able to add rows or delete rows as i please. The problem is that if I enter a number in an element of the array and i add a row it blanks out whatever I had written. Attached is my code. I think there should be a simple solution to this coz i havent been able to find much online help to it.
    Attachments:
    test-1.vi ‏208 KB

    The changes of the array values are not recorded in the shift register. You have to catch another event : the array value change, and pass the new array value to the right shift register.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • How to replace cluster element in an array?

    hi,
    I have understood preferable choice is to initialise array first and replace elements in an array instead of inserting new element in an array e.g. in a while loop.
    So I started to this evaluate since I have an application where I want to read lots of measurements from a txt file and display them in a XY graph. XY graph must show Y value and corresponding X value either red if it is out of range and in green if it is in range. I found a solution to do it with an array of clusters.
    In attached example I have two different methdologies represented. My problem is that upper solution doesn't display content of all measurements. Can somebody tell me what I'm doing wrong ?
    regards,
    petri
    Solved!
    Go to Solution.
    Attachments:
    plot test 3.vi ‏19 KB

    Petri wrote:
    ... using cluster with three elements was a method I found to put red and green dots in one XY graph, eg. Y=coordinateY, X(green)=NaN,X(red)=coordinateX. Perhaps there is a better way to display the data, but I couldn't find it.
    That is an odd thing and makes little sense. Why three? four, five, etc are NOT supported, so what if you want more than one color? (in range, fail high, fail low?). For more detail see the discussion here.
    In any case, reading all these values from a datafile and creating xy plots is trivial. I would recommend to use complex data. a single complex array will graph IM vs RE. For multiple plots, combine them using "build cluster array". No loops needed.
    Here's a quick draft. Of course you need to decide if the data is in columns or rows, etc. so modify as needed.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    plot2XY.PNG ‏7 KB

  • Adding an element in an array of cluster of 2 elements

    Hi all,
    I have a 1D array containing a cluster of 2 numeric elements (= 2 rows of 100 values).
    From this array, collecting new data in for loop, I want to create another array containing a cluster with 9 elements: in each for I want to add an element (= like one row).
    After this, I want to compare data from one element with a fixed value, and when the value is find in the element, I want to extract the values of the 8 other elements at this point.
    Thanks
    Dze

    Sorry I didn't understand you well. To use only arrays, you'll need 3D arrays, as you can see in the example attached. I've made two variants, one with your method (don't know if there's an easyer one) and one with the method I think is easyer, after that, you can search in the 3D array easyer that in the array of clusters of arrays (uff...). If I misanderstood you again, please let me know.
    Hope this helps
    Attachments:
    arrayclusterarray.llb ‏50 KB

  • Shifting elements in multidementional array

    Hello,
    I'm working on a boardgame project which uses an int[][] to represent the board. The elements in this array are numbers which represent vehicles. The equal numbers are one vehicle. A vehicle can perform a step left/right, or a step up/down (if there is no other vehicle blocking the way of course).
    I've read about the arraycopy method, but I don't know how to use it with an array of arrays.
    So an example of the matrix would look like this:
    111002
    300502
    344502
    300500
    000000
    666000
    After a step of one vehicle the matrix could be:
    011102
    300502
    344502
    300500
    000000
    666000
    I need to get matrices for all possible moves, for all vehicles.
    I couldn't find any documentation about the use of copyarray with an array of arrays. Hope someone can point me in the right direction.
    Thanks in advance

    Ceylor wrote:
    Hello all,
    thanks very much for the quick replies.
    prometheuzz, I've read the topic you mentioned and your explanation is great. Your UML makes it very clear.You're welcome.
    I allready use OOP as much as possible. In my project I use a playField class (the board, also GUI), a node class (extends from rectangle, a cell in the field), a vehicle class (contains a collection of nodes and some other properties), a class for my algoritm and a state class.Good to hear that.
    The state class is used for storing all possible states of the playField. (ie all valid moves). These states are needed for a shortest path algoritm, and are not automatically a state the playField gets. Therefor I can't use the vehicles stored in the playField class because this class only contains the initial state of the game. The playField only get's updated when the algoritm is done and a shortest path is found. So would it be a good solution to store a collection of vehicles inside my state class?I'm don't quite follow you here, I'm afraid.
    The thing I'm a bit worried about is that there can be a lot of states. When adding the vehicles to each state object, doesn't this slow things down?
    ...Don't worry about inefficient code too soon. First get your logic correct: check your algorithm against a small puzzle, ensure that it works. After that, try some larger puzzles to see if a solution is found within the required time frame. If it takes too long, only then adjust your algorithm.
    Feel free to post back if you have any questions.
    Good luck.

  • Finding the smallest value from an array

    Hi there :)
    I started learning Java a few days ago and have now run into my first problem :p
    I am using Netbeans on Mac OS X.
    I need to find the smallest value from an array. So far I've had no luck. Any suggestions would be fantastic.
    The code so far:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
            int O = A.length - 3;
            int B = A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7] + A[8] + A[9] + A[10] + A[11] + A[12] + A[13] + A[14];
            A[15] = B;  // Stores the sum of the integers in A[15]
            int C = B / O;
            A[16] = C;  // Computes and stores the average in A[16]
            int D = 101;
                if (A[0] < A[1]) { D = A[0]; }
                else { D = A[1]; }
                if (A[1] < A[2]) { D = A[1]; }
                else { D = A[2]; }
            System.out.println("There are " + O + " numbers in the Array");
            System.out.println("Those numbers add up to " + B + ".");
            System.out.println("The average of those numbers is " + C + ".");
            System.out.println("The smallest value in the array is " + D + ".");
    }The code is incomplete, but it works so far. The problem is I know there must be an easier way. SAVE ME :)

    OK :)
    Just thought I should show you the output as to help anyone else with the same problem:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17                           // COMPLETED
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    import java.util.Arrays;
    public class Main { 
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
         public static void main(String[] args) {
                  int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
              Arrays.sort(A);
              System.out.println("The smallest value in the array is " + A[0] + ".");
              int num = A.length;
              System.out.println("There are " + num + " values in the Array.");
              int sum = 0;
              for (int i = 0; i < A.length; i++) {
                   sum+=A;
              System.out.println("Those numbers add up to " + sum + ".");
              double d = (double)sum/num;
              System.out.println("The average value of those numbers is " + d + ".");
    What Iearned:
    1) How to create for loops properly
    2) How to import java.util.Arrays ( =D )
    3) How to get a more accurate average using double instead of int
    4) This forum is the best and has very helpful people 24/7 ( =D)
    Thanks Again,
    Mo.

  • How do I display all the elements of an array?

    Hello,
    I am trying to learn about manipulating arrays.  The example finder includes this one," build array_forum.vi", which shows the two modes, concatenate and append, which I can understand, HOWEVER, I cannot figure out how they built this vi.  For example, I can find the Build Array function, but, I cannot understand how they created the "array of numeric data 1"  "array of numeric data 2"...etc, and I cannot find the functions on the palettes that result in the display "build array concatenate inputs".  Where are these blue functions????
    Where are these functions found on the palette, and how does one construct them like this? 
    The other vi shown here, "for loop array_forum.vi" is my attempt to duplicate it, but, it does not show all the elements of the array; instead it displays only ONE element, the last element of the array.  How do I display all the elements of the array I am trying to create using the FOR LOOP?
    Thanks,
    dave
    Solved!
    Go to Solution.
    Attachments:
    for loop array_forum.vi ‏7 KB
    Build Array_forum.vi ‏12 KB

    I think I posted this in the wrong place.  I reposted this to the Labview forum.
    Dave

  • Is there a way of determining what element in an array is being clicked on?

    Hi all.  I would like to setup an event to determine what element in an array is being clicked on/hovered over.  I think I tried this before and found it wasn't working due to limitations of LV 7.0.  If this code already exists, it would be great if I don't have to do a scavenger hunt for the solution.
    I think one possibility I nixed was to use the refnum of the elements to determine which one it is.  IIRC, this is not possible because the refnum of the element is for the edit box only.
    The second possiblity is to get the on click event, and somehow determine which element in the array it is.  This doesn't sound too difficult as it should be a simple calculation, but may get in to some hairryness based on if the indicies are visible or not, and if I am using a new or old array with new or old control (calc would change based on boarder size of the controls).  I might just simplify it by removing indicies and using older control set which has minimal boarder size.
    And just for fun, can I force a tool tip to show up?
    Thanks all,
    A
    Using LV7.0 on WinXP.

    blawson wrote:
    Been bitten by LabVIEW wrote:
    I think one possibility I nixed was to use the refnum of the elements to determine which one it is.  IIRC, this is not possible because the refnum of the element is for the edit box only.
    Using LV7.0 on WinXP.
    This is indeed possible, at least in the newer versions I use.
    Take the array refnum from the click event data terminal and get a reference to the array element.  This refers to the element that was clicked, but you do need to work out how to get the index.  My method is to use property nodes to get the screen position and size of the element and the screen position and size of the array, as well as the array's Visible Index property. For each direction, take the quotient of the relative position of the element (account for padding!) over the size of an element.
    I suspect that taking the mouse coords and comparing to the array's sizes in pixels is similar, although I trust my method for events that don't have mouseclicks (what coords does Array:shortcut menu selection(User) return if you used the keyboard?)
    Here's an old version I happened to have open.  I've posted about this before, I suspect I have a clearer version in my gallery.  I use this method in my example code contest entry to work out which square of the chessboard is clicked.
    Thank you for that one!
    I am currently "locked up behind a down-rev fence" (working an old app in an old version) so I had not heard of that.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • How to print  Excel file in java?

    Hi, all I had written a program to generate a Report with Excel in java using the jexcelapi_2_5_7 . But I don't know how to print it in java program. It seems that java print Service don�t support Excel flavor. How should I do? It will be a great app

  • Will Windows 8.1 upgrade work with Boot Camp on OS X Mavericks?

    Will Windows 8.1 upgrade work with Boot Camp on OS X Mavericks?

  • Co-operating tags? ... cooperating siblings, not ancestors

    i have a JSP with a few sibling custom tags: <a:sibling1 .../> <a:sibling2 attr2="value" /> <a:sibling3 .../> Now, I need the value of the attribute "attr2" of the tag "sibling2" for all my tags - sibling1/2/3/etc - to work ... (once i get the value

  • Securing my MacBook on a Open Wifi Network

    Ive been using some open wifi networks that I have been finding all over the place, does this mean they can access my macbook? How do i make sure that i can use these open wifi networks but thay can access my files? Thanks in advance. Macbook   Mac O

  • 2LIS_04_P_MATNR Delta - Actual Start and Finish Dates

    My company is experiencing a problem with retrieving the actual start and finish dates and times from the 2LIS_04_P_MATNR data source with delta extraction. The R/3 source system is version 4.6C. The BI system is version 7.0. Specifically, the data s