Choosing every n-th element of string array

Hi,
I want to load into memory series of thermograms. The thing is I can get all of them (180) read although I need to improve/compare the results of FFT performed on them - so I want to 'change the sampling frequency' so I will load every 2nd, 3rd, 4th,.. 9th termogram. That would be chosen by the user. 
How am I supposed to alter the 1d array of strings with paths so only every n-th element will be in output array? I attached the VI that gets coma as the first array element. 
Michał
Solved!
Go to Solution.
Attachments:
openMultiple_.vi ‏20 KB

natasftw wrote:
With the new conditional tunnel, wouldn't it be easier to just feed the remainder into an Equals 0? and use that true/false as the tunnel condition to build the array that way instead of using multiple array functions to get the same result?
The explicit method is more efficient because the size of the output is exactly defined. With the conditional tunnel, the final number of elements is not known and thus cannot be correctly allocated in one operation.
Also, a Q&R operation is more expensive than a multipliucation. You could even do an addition in a shift register instead.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • How to assign element to String[] array?

    For example::
    String[] array={ "abcd" , "1234","Noman","java"} ;
    Suppose i want to replace ' 2 ' by ' x ' how i will do that ?

    As PhHein said: String are immutable.
    You can do like this:
        String[] strA = new String[]{ "abcd" , "1234","Noman","java"} ;
        for ( int i = 0; i<strA.length; i++) {
          String string = strA;
    if(string.contains("2")){
    string = string.replace('2', 'x');
    strA[i] = string;
    System.out.println(string);
    System.out.println(Arrays.toString(strA));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Append a constant string to every element in an array

    Hi Friend,
    I have a small stuck in my labview program that is I need to append a constant string to each element of an array. Could someone provide guidance on this? Prior thanks to your help.
    Have a nice day!
    Lee Joon

    Pass the array into a for loop with autoindexing; concatenate each element with the constant and then use the array output from the loop...
    I was a few seconds behind the post above; great minds think alike!
    Message Edited by Phillip Brooks on 11-15-2007 08:42 AM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    Append String.gif ‏33 KB

  • How to add elements into java string array?

    I open a file and want to put the contents in a string array. I tried as below.
    String[] names;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
                    String item = s.next();
                    item.trim();
                    email = item;
                    names = email;
                }But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

    Actually you cannot increase the size of a String array. But you can create a temp array with the lengt = lengthofarray+1 and use arraycopy method to copy all elements to new array, then you can assign the value of string at the end of the temp array
    I would use this one:
    String [] sArray = null;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
        String item = s.next();
        item.trim();
        email = item;
        sArray = addToStringArray(sArray, email);
    * Method for increasing the size of a String Array with the given string.
    * Given string will be added at the end of the String array.
    * @param sArray String array to be increased. If null, an array will be returned with one element: String s
    * @param s String to be added to the end of the array. If null, sArray will be returned.(No change)
    * @return sArray increased with String s
    public String[] addToStringArray (String[] sArray, String s){
         if (sArray == null){
              if (s!= null){
                   String[] temp = {s};
                   return temp;
              }else{
                   return null;
         }else{
              if (s!= null){
                   String[] temp = new String[sArray.length+1];
                   System.arraycopy(sArray,0,temp,0,sArray.length);
                   temp[temp.length-1] = s;
                   return temp;
              }else{
                   return sArray;
    }Edited by: mimdalli on May 4, 2009 8:22 AM
    Edited by: mimdalli on May 4, 2009 8:26 AM
    Edited by: mimdalli on May 4, 2009 8:27 AM

  • WebService problem: only the first element of a string array is returned

    Hello,
    i did the J2EE QuickCarRental tutorial and extended it by some features: I created another entity bean and implemented four new methods in the QuickOrderProcessor. Then i deployed it as a WebService and accessed it using the Visual Composer.
    Everything works fine except the return value of one WebService method. I created a method with the return value String[]. But the Visual Composer reads it as String. Only the first element of the resulting string array is displayed. Although the test at the web-page http://<server>:<port>/QuickCarRentalService/Config1 displays the whole string array with all its elements. What did i wrong?
    Another problem is that after deploying the J2EE-Application with new WebService methods the changes are not visible inside the visual composer. Although the test at the web-page http://<server>:<port>/QuickCarRentalService/Config1 displays the changes. Do i have to restart the WebService system in the portal content? If yes how can i do that?

    Here are details about setting up and using web services and some examples:
    /people/prakash.darji/blog/2006/10/10/external-web-service-proxy-configuration-for-visual-composer

  • Combining string array elements into one string

    Right, I have an string array called str which stores 1 character in each of its 16 elements. It gets this character from another array, strArray. Now, what I want to be able to do is to take all 16 elements and combine them into one string called keyString. Using the code below keyString only prints out the last character. The code is shown below:
    for (x=0; x<16; x++) {
         str = new String[16];
         str[x] = "";
         str[x] += (strArray[(index+x)%16].charAt(strChar[x]));
         keyString = str[x];
           System.out.print(keyString);
    }Any help would be very much appreciated.
    Edited by: Paragon96 on May 20, 2008 7:32 AM

    your logic is wrong ; if you want to concatenate the content of the array, you have to loop (what you did), and concatenate keyString for each index, meaning:
    keyString += str[x];you can also use a StringBuilder for such kind of operations

  • Is there an easy way to replace individual elements in one string array from another striing array?

    I have a string array with elements as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 5E 00 00 00
       00 00 50 00 30 00 33 00
       34 00 39 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    The array I want to use to replace values with is:
    43 4E 31 30 30 33 30 30 31 41
    Where 43 goes in the 3rd row fifth position
    Where 4E goes in the 3rd row seventh position
    Where 31 goes in the 4th row  first position
    Where 30 goes in the 4th row third position
    Where 30 goes in the 4th row fifth position
    Where 33 goes in the 4th row seventh position
    Where 30 goes in the 5th row  first position
    Where 30 goes in the 5th row third position
    Where 31 goes in the 5th row fifth position
    Where 41 goes in the 5th row seventh position
    So the final array looks as follows:
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
       00 00 00 00 43 00 4E 00
       31 00 30 00 30 00 33 00
       30 00 30 00 31 00 41 00
       00 00 00 00 00 00 00 00
       00 00 00 00 00 00 00 00
    Is there an easy way to replace an element of a string within an array with another element of a string within a different array?
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA (temp).vi ‏13 KB

    Try this
    Omar
    Message Edited by Omar II on 03-24-2010 03:25 PM
    Omar
    Attachments:
    CMM_Add_SCAN_SN_2_PAT_DATA%20(temp)[1].vi ‏17 KB

  • How to check string array elements with a string with in one forEach tag ?

    Hi All,
    I am new to JSTL and EL. I need to change the following Java code into JSTL and EL.. I struggled to change this code into JSTL.
    How can i change the if loop which tests the string array element with one bean property ?
    -------------------------------------------------------------------------------------------------------------for(int j=0 ; j < iSelectedCount; j++)
    if(strSelectedRoleId[j].equals(lineRole.getRoleID()))
    isAvailable = true;
    Please help me on this.
    It is very urgent......
    Thank you for ur help,
    Natraj

    import java.util.Calendar;
    Calendar rightNow = Calendar.getInstance();  // gets the current date and time to millisec
    Calendar earlyTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 6).set(Calendar.MINUTE, 30);
    Calendar lateTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 8).set(Calendar.MINUTE, 0);
    if (rightNow.compareTo(earlyTime)> 0 && rightNow.compareTo(lateTime) < 0){
    // do something
    }Try this.

  • Printing every possible pair combination of elements in two arrays??

    Hi there,
    I'm trying to implement the problem of printing every possible pair combination of elements in two arrays. The pattern I have in mind is very simple, I just don't know how to implement it. Here's an example:
    g[3] = {'A', 'B', 'C'}
    h[3] = {1, 2, 3}
    ...code...??
    Expected Output:
    A = 1
    B = 2
    C = 3
    A = 1
    B = 3
    C = 2
    A = 2
    B = 1
    C = 3
    A = 2
    B = 3
    C = 1
    A = 3
    B = 1
    C = 2
    A = 3
    B = 2
    C = 1
    The code should work for any array size, as long as both arrays are the same size. Anybody know how to code this??
    Cheers,
    Sean

    not a big fan of Java recursion, unless tail recursion, otherwise you are bound to have out of stack error. Here is some generic permutation method I wrote a while back:
    It is generic enough, should serve your purpose.
    * The method returns all permutations of given objects.  The input array is a two-dimensionary, with the 1st dimension being
    * the number of buckets (or distributions), and the 2nd dimension contains all possible items for each of the buckets.
    * When constructing the actual all permutations, the following logic is used:
    * take the following example:
    * 1    2    3
    * a    d    f
    * b    e    g
    * c
    * has 3 buckets (distributions): 1st one has 3 items, 2nd has 2 items and 3rd has 2 items as well.
    * All possible permutaions are:
    * a    d    f
    * a    d    g
    * a    e    f
    * a    e    g
    * b    d    f
    * b    d    g
    * b    e    f
    * b    e    g
    * c    d    f
    * c    d    g
    * c    e    f
    * c    e    g
    * You can see the pattern, every possiblity of 3rd bucket is repeated once, every possiblity of 2nd bucket is repeated twice,
    * and that of 1st is 4.  The number of repetition has a pattern to it, ie: the multiplication of permutation of all the
    * args after the current one.
    * Therefore: 1st bucket has 2*2 = 4 repetition, 2nd has 2*1 = 2 repetition while 3rd being the last one only has 1.
    * The method returns another two-dimensional array, with the 1st dimension represent the number of permutations, and the 2nd
    * dimension being the actual permutation.
    * Note that this method does not purposely filter out duplicated items in each of given buckets in the items, therefore, if
    * is any duplicates, then the output permutations will contain duplicates as well.  If filtering is needed, use
    * filterDuplicates(Obejct[][] items) first before calling this method.
    public static Object[][] returnPermutation(Object[][] items)
         int numberOfPermutations = 1;
         int i;
         int repeatNum = 1;
         int m = 0;
         for(i=0;i<items.length;i++)
              numberOfPermutations = numberOfPermutations * items.length;
         int[] dimension = {numberOfPermutations, items.length};
         Object[][] out = (Object[][])Array.newInstance(items.getClass().getComponentType().getComponentType(), dimension);
         for(i=(items.length-1);i>=0;i--)
              m = 0;
              while(m<numberOfPermutations)
                   for(int k=0;k<items[i].length;k++)
                        for(int l=0;l<repeatNum;l++)
                             out[m][i] = items[i][k];
                             m++;
              repeatNum = repeatNum*items[i].length;
         return out;
    /* This method will filter out any duplicate object in each bucket of the items
    public static Object[][] filterDuplicates(Object[][] items)
         int i;
         Class objectClassType = items.getClass().getComponentType().getComponentType();
         HashSet filter = new HashSet();
         int[] dimension = {items.length, 0};
         Object[][] out = (Object[][])Array.newInstance(objectClassType, dimension);
         for(i=0;i<items.length;i++)
              filter.addAll(Arrays.asList(items[i]));
              out[i] = filter.toArray((Object[])Array.newInstance(objectClassType, filter.size()));
              filter.clear();
         return out;

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • After an element in the array is removed, how to move the array up?

    Hi,
    My programs creates an array of strings. The user can choose to insert or delete a string. After a string has been deleted, I like to move the rest of the array up to fill up the space. For examples,
    String[] before={"This", "is", "a", "test"};
    After "a" is removed, instead of assign null to the space, I like to move "test" up so it becomes
    String[] after={"This", "is", "test", null};
    Can anyone help?
    Thanks.

    well i'm not doing your homework but the answer is three steps and two
    loops
    step one create a new array "after" one less than the size of your original "before".
    step two loop through the elements of "before" up to the element
    that was removed. add these elements to the "after" array.
    step three loop through the elements of "before" starting at the
    element after the one that was removed. add these elements to the
    "after" array.
    now when you get this done there is a better way to do this other than
    loops. use System.arraycopy() you can see the api for that here...
    http://java.sun.com/j2se/1.4/docs/api/java/lang/System.html

  • 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.

  • Breaking up a String array

    Hi guys!
    I have been working on this for a while! I have an assignment which requires:
    -take input of a seven digit integer
    - break this number apart and perform calculations in order to "encrypt" the number.
    -etc..
    I thought I should break the string up first, then convert each element to an int for calculations.
    I am sure there is a better way to do this.
    Could I use a String Tokenizer? How would I do that?
    Thanks!!
    Here's what I have so far:
    import javax.swing.*;
    public class Assignment3 {
      public static void main( String args[] ) {
        String choiceString = "",
        output = "",
        stringArray[] = new String[7];
        int intArray[] = new int[7],
        choiceInt;
        while ( choiceString != null ) {
          // prompt user to input a seven digit integer
          choiceString=JOptionPane.showInputDialog("Please     enter the number corresponding to your choice:\n1.Encryption\n2.Decryption\n3.Exit");
          choiceInt = Integer.parseInt( choiceString );
         if( choiceInt != 1 || choiceInt != 2 || choiceInt != 3)
            JOptionPane.showMessageDialog( null, "Invalid selection", "Error",
            JOptionPane.ERROR_MESSAGE );
          // 1=encrypt 2=decrypt 3=exit
          switch ( choiceInt ) {
            case 1:
             stringArray = JOptionPane.showInputDialog( "Please enter a seven digit number:" ) ;
              intArray = convert( stringArray );    // converts string to int
              digitSwap1( intArray );   
              nineModTen( intArray );
              digitSwap2( intArray );
              output += "Original: " + input + "\nOutput: " +  intArray;
              break;
            case 2:
              stringArray = JOptionPane.showInputDialog( "Please enter an encrypted number: " );
              intArray = convert( stringArray );
              digitSwap2( intArray );
              decrypt( intArray );
              digitSwap1( intArray );
              output += "Decrypted: " + input + "\nOutput: " + intArray;
              break;
            case 3:
              output += "Thank you, have a nice day";
              break;
            default:
              JOptionPane.showMessageDialog( null, "Please make a selection", "Error",
              JOptionPane.ERROR_MESSAGE );
              break;
          } // end switch
          JOptionPane.showMessageDialog( null, output, "Results",
          JOptionPane.INFORMATION_MESSAGE );
        } // end loop
        System.exit(0);
      } // end main
      public static void digitSwap1( int array[] )
        int digit1,digit2,digit3,digit4,digit5,digit6,digit7;
        digit1 = array[0];
        digit2 = array[1];
        digit4 = array[3];
        digit5 = array[4];
        digit6 = array[5];
        digit7 = array[6];
        array[0] = digit7;
        array[1] = digit6;
        array[2] = digit5;
        array[4] = digit3;
        array[5] = digit2;
        array[6] = digit1;
        } // end digitSwap1
      public static void nineModTen( int array[] )
        int x = 0;
        while ( x <= 6 ) {
          array[x] = ( array[x] + 9 ) % 10;
          x++;
        } // end loop
      }  // end nineModTen
      public static void digitSwap2( int array[] )
        int digit1,digit2,digit3,digit4,digit5,digit6,digit7;
        digit1 = array[0];
        digit2 = array[1];
        digit3 = array[2];
        digit4 = array[3];
        digit5 = array[4];
        digit6 = array[5];
        array[0] = digit2;
        array[1] = digit1;
        array[2] = digit4;
        array[3] = digit3;
        array[4] = digit6;
        array[5] = digit5;
      }  // end digitSwap2
      public static void decrypt( int array[] )
        int x = 0;
        while ( x <= 6 ) {
          if ( array[x] < 9 )
            array[x] += 1;
          else
            array[x] = 0;
          x++;
        }  // end loop
      } // end decrypt
      public static int[] convert( String array1[] )
        int array2[] = new int[7];   
        int count = 0;
        while ( count <= 6 ) {
          array2[count] = Integer.parseInt( array1[count] );
          count ++;
        } // end loop
        return( array2 );
        } // end convert
    } // end class

    I have solved my problem! The real problem was that I
    was trying to output my resulting int array like this:
    output = "result: " + intArraybut I discovered that when I concatenated each individual
    element in the array, it worked fine:
    output = "result: " + array[0] + array[1] ....Also, I found an easy way to break up the input. Rather
    than use the charAt() method to extract each digit, and
    then convert for calculation, I converted the String to int
    and then, in a loop, extracted each digit from last to
    first by: (array[count] = number% 10), then (number = number / 10).
    Thanks everyone for your help! I hope this will help
    someone else too. Below is the working code.
    ; > -HB
    // this program takes a 7 digit input and "encrypts" it
    // by 1st, swapping some of the digits, 2nd, add nine
    // and mod ten to each digit, 3rd, swapping digits again.
    import javax.swing.*;
    public class Assignment3 {
      public static void main( String args[] ) {
        String choiceString = "",
        output = "",
        input;
        int number;
        int intArray[] = new int[7],
        choiceInt = 0;
        while ( choiceString != null ) {
          // prompt user to choose an option
          choiceString=JOptionPane.showInputDialog("Please enter the number corresponding to your choice:\n1.Encryption\n2.Decryption\n3.Exit");
          choiceInt = Integer.parseInt( choiceString );
          // 1=encrypt 2=decrypt 3=exit
          switch ( choiceInt ) {
              case 1:
              input = JOptionPane.showInputDialog( "Please enter a seven digit number:" );
              number = Integer.parseInt( input );
              intArray = convert( number );    // extract each digit
              intArray = digitSwap1( intArray );   
              nineModTen( intArray );
              intArray = digitSwap2( intArray );
              output = "Original: " + input + "\nOutput: " + intArray[0] +
                       intArray[1] + intArray[2] + intArray[3] +
                       intArray[4] + intArray[5] + intArray[6];
              JOptionPane.showMessageDialog( null, output, "Results",
              JOptionPane.INFORMATION_MESSAGE );
              break;
            case 2:
              input = JOptionPane.showInputDialog( "Please enter an encrypted number: " );
              number = Integer.parseInt( input );
              intArray = convert( number );
              intArray = digitSwap2( intArray );
              decrypt( intArray );
              intArray = digitSwap1( intArray );
              output = "Decrypted: " + input + "\nOutput: " + intArray[0] +
                       intArray[1] + intArray[2] + intArray[3] + intArray[4] +
                       intArray[5] + intArray[6];
              JOptionPane.showMessageDialog( null, output, "Results",
              JOptionPane.INFORMATION_MESSAGE );
              break;
            case 3:
              break;
            default:
              JOptionPane.showMessageDialog( null, "Please make a valid selection", "ERROR", JOptionPane.ERROR_MESSAGE);
              break;
          } // end switch
          if ( choiceInt == 3 )
            break;
          } // end loop
          JOptionPane.showMessageDialog( null, "Thank you, Have a nice day!", "EXIT",
          JOptionPane.PLAIN_MESSAGE );
        System.exit(0);
      } // end main
        public static int[] convert( int num )
          int array[] = new int[7];
          int count = 6;
          while ( count >= 0 ) {
            array[ count ] = num % 10;
            num = num / 10;
            count --;
          return array;
      } // end convert
      public static int[] digitSwap1( int array[] )
        int digit1,digit2,digit3,digit5,digit6,digit7;
        digit1 = array[0];
        digit2 = array[1];
        digit3 = array[2];
        digit5 = array[4];
        digit6 = array[5];
        digit7 = array[6];
        array[0] = digit7;
        array[1] = digit6;
        array[2] = digit5;
        array[4] = digit3;
        array[5] = digit2;
        array[6] = digit1;
        return array;   
      } // end digitSwap1
      public static void nineModTen( int array[] )
        int count = 0;
        while ( count < 7 ) {
          array[count] = ( array[count] + 9 ) % 10;
          count++;
        } // end loop
      }  // end nineModTen
      public static int[] digitSwap2( int array[] )
      int digit1,digit2,digit3,digit4,digit5,digit6;
        digit1 = array[0];
        digit2 = array[1];
        digit3 = array[2];
        digit4 = array[3];
        digit5 = array[4];
        digit6 = array[5];
        array[0] = digit2;
        array[1] = digit1;
        array[2] = digit4;
        array[3] = digit3;
        array[4] = digit6;
        array[5] = digit5;
        return array;
      }  // end digitSwap2
      public static void decrypt( int array[] )
        int count = 0;
        while ( count <= 6 ) {
          if ( array[count] < 9 )
            array[count] += 1;
          else
            array[count] = 0;
          count++;
        }  // end loop
       } // end decrypt
      } // end class

  • How do you assign multiple values to a single element in an array?

    I'm probably not wording the question right.
    I have an array, let's call it M[], and for each element in the array (we'll say M[1]), I need assign three integers: row, col and value.
    I need to set it up so I can do something like this:
    A.row = M[i].col;
    A[i].col = M[i].row;
    A[i].value = M[i].value;
    The algorithm isn't what I need help with, it's assigning .col, .row and .value to an index of an array.
    Please help if you can.

    You are right. You did not word your question perfectly, but I still think I get what you want.
    First of all: A single element in an array always has exactly one value. No more, no less.
    But that's not a problem. The element in an array is either of a primitive type (boolean, byte, char, short, int, long, float, double) or it's a reference (to a Object, String, MyClass, ...).
    You can simply write a class that holds your three values and create an array of that type:
    public class SomeData {
      public int row;
      public int col;
      public int value;
    // somewhere else:
    SomeData[] a = new SomeData[10];
    a[0] = new SomeData();
    a[0].row = 10;
    a[0].col = 5;
    a[0].value = 42;Note how you only assign a single value to the element (a[0]) itself. All other assignment actually go to fields of the object refered to by that element in the array.
    Also note that in Java types (such as classes, interfaces, ...) should start with a upper-case letter, while variables (local variables, members, parameters) and method names should start with a lower-case letter.
    Edit: I'm getting old ...

  • How can I change the properties of only one element in an array of booleans?

    I'm displaying an array of booleans to my operators, with each boolean in the array representing some system status check.  Some of these checks are critical and some are not, therefore I want some of these booleans to have a different color when in the TRUE state (Red for the critical ones and Yellow for the non-critical ones).  I can change the boolean colors with a property node, but that effects every element in the array.  Is there any way to change a property of an individual element in an array?  I know that I could take the incoming array and break it into two arrays - one for critical and one for non-critical, but this system is replacing an older system and the operators are accustomed to seeing their indicator lights a certain way and I'm trying to replicate what they had exactly.

    Here's what I had in mind
    Of course you can use as many colors as you want.
    Message Edited by altenbach on 12-21-2005 04:53 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    LEDarray.png ‏7 KB
    ColorArray3.vi ‏23 KB

Maybe you are looking for

  • Problem with CS3 Master Collection on new Box & WinXP

    I just got a new computer, specs given bellow, that I just installed CS3 Master Collection.  The installation was reported as successful but when I try to run any of the CS3 programs (Flash, Photoshop, etc) the process starts (I checked this with Wid

  • "Organize Imports" feature in Jdev10g will totally mess up my source code

    I set "Use Wide Imports". The source code became a piece of junk after running "Organize Imports" against following code: * @author package test; import java.io.*; import java.util.*; import javax.xml.parsers.*; import org.apache.xerces.util.XMLChar;

  • Executing OIM Process task based on Condition

    Hi Experts , I have the following requirement : when a OIM user field - X is updated with a value A i have to call task T1, generate a random number on this task and have to trigger CREATE user Task within in the same process definition of an IT reso

  • Using more than one component to a back end bean

    I have to ask, if i use a component more than once on a page eg                     <tr:panelGroupLayout>                          <tr:selectOneChoice id="HPIDesc" label="HPI Description" value="#{iPISelectBean.selectValue}" >                        

  • HT1692 My Contacts synced once to my iPod, how do I get them to sync again with updates?

    My Outlook Contacts synced to my iPod once (after finally finding out how to so that). Since then it has never synced with Contacts again. It syncs the music just fine. Some instructions I have read mention an "Info Tab" after selecting the device. I