Moving through array backwards

Hi guys,
Im new to java and i have a small query. I have an array which i have found the maximum value of using the code below. I want to be able to move back through the array(the maximum value is at rightmost element).
Any suggestions as the best way to do this(im a little confused!)
thanks
java.util.Arrays.sort(votesArray);
int max = votesArray[votesArray.length-1];
System.out.println("Elected =" + votesArray[votesArray.length-1]);

This will do it:
import java.util.Arrays;
public class ReverseArrayTester
    public static void main(String [] args)
        if (args.length > 0)
            Arrays.sort(args);
            for (int i = 0; i < args.length; ++i)
                System.out.println(args[args.length-1-i]);
}MOD

Similar Messages

  • Moving through a vector

    Help
    I have retrieved the data below from a database and stored into a vector. (each row is stored into an array and in turn each row is stored into a vector). Now I have to show this data quarterly (add january, feb and mar into one quarter and so on.. I am having problems moving through this vector. Any help is appreciated.
    Sue
    Year Period Labor Force Employment Unemployment Unemployment Rate
    1998 January 3,423 3,249 174 5.10
    1998 February 3,379 3,199 180 5.30
    1998 March 3,390 3,225 165 4.90
    1998 April 3,398 3,244 154 4.50
    1998 May 3,455 3,326 129 3.70
    1998 June 3,564 3,403 161 4.50
    1998 July 3,617 3,479 138 3.80
    1998 August 3,629 3,489 140 3.90
    1998 September 3,546 3,410 136 3.80
    1998 October 3,574 3,409 165 4.60
    1998 November 3,561 3,368 193 5.40
    1998 December 3,476 3,298 178 5.10
    1998 Annual Average 3,501 3,342 159 4.50

    Here's is some pseudocode that might help. Of course, I did this quickly so, there might be a few syntax errors, etc. but you should be able to get the general idea. This might not be the most efficient way either, but it's the first thing I thought of.
        Vector data; //your vector of arrays
        Vector quarterData = new Vector(); //vector of vectors for storing data totals for all 4 quarters
        for (int q = 0 ; q < data.size(); q +=3 )
            int laborTotal = 0;
            int empTotal = 0;
            int unempTotal = 0;
            int unempRateTotal = 0;
            int unempRateAvg = 0;
            int startindex = q;
            int stopindex = q + 3;
            Vector thisQuarterData = new Vector(); //vector of totals for this quarter (will be added to Vector quarterData)
            //loop through each array for this quarter
            while ( startindex < stopindex )
                //access appropriate arrays in Vector data using the startindex as index
                //add values to quarterTotals
                //i.e. go through array and add to totals
                startindex++;
            unempRateAvg = unempRateTotal/3; //find quarter average
            //add totals to this quarters data vector
            thisQuarterData.add(laborTotal);
            thisQuarterData.add(empTotal);
            thisQuarterData.add(unempTotal);
            thisQuarterData.add(unempRateAvg);
            quarterData.add(thisQuarterData);
        }You will then have all of your quarterly data in the Vector quarterData which you can then loop through and output.
    Hope this helps,
    --Nicole                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Just recently my iPad started to get lazy on me I'll go on a website and it has trouble moving through the different applications within it. It has nothing to do with the wifi because it's doing it no matter what wifi it is using at the time.

    Just recently my iPad started to get lazy on me I'll go on a website and it has trouble moving through the different applications within it. It has nothing to do with the wifi because it's doing it no matter what wifi it is using at the time?

    Not sure what you are talking about.

  • Shortcut for moving forward and backward through Time Machine

    It seems obvious that there should be keyboard shortcuts for moving backward and forward through time in the Time Machine. Anyone know how?

    V.K. wrote:
    it might seem obvious but AFAIK there are no shortcuts for that. use the mouse.
    I can't imagine replacing a simple mouse click with something like
    Cmd-Ctl-Shift-Fn12-page up
    It's noticeable that the menu disappears when entering TM, meaning that the usual assignments of shortcuts in the KB menu have, at least for the present, unknown values, if any at all.
    What kind of shortcut would take me back to December 25, 2007 anyway? The trackpad and trackpad bar work.
    It's possible to open TM with a shortcut or script, but from there one is on the dark side.
    Message was edited by: nerowolfe

  • Problem moving through CardLayout

    Hi,
    I have been unable to find any solid examples of CardLayout, so I have been using some code I found in this forum. I'm getting hung up on how to move forward or backwards through the cards. I know it is myCard.next but for some reason I'm getting hung up on which card I should be referencing and how to associate that card with the code. Perhaps someone could spot the error...
    Thanks,
    Steve
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class CardLayoutQuestionsv2 {
        public static void main(String[] arguments) {
            JFrame frame = new Interface();
            frame.show();
    class Interface extends JFrame {
         private dataPanel screenvar;
    //     private questionPaneOne abcdef;
         private JTextArea msgout;
         JPanel cardPane;
         Interface () {
              super("This is a JFrame");
            setSize(800, 400);  // width, height
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // set-up card layout
              cardPane = new JPanel();     // for CardLayout
              CardLayout questions = new CardLayout();
              cardPane.setLayout(questions);
              cardPane.setBorder(BorderFactory.createCompoundBorder(
                                              BorderFactory.createMatteBorder(
                                                              1,1,2,2,Color.blue),
                                    BorderFactory.createEmptyBorder(5,5,5,5)));
              cardTestOnePane     cardOne = new cardTestOnePane();
              cardTestTwoPane     cardTwo = new cardTestTwoPane();
              cardPane.add("questionOne", cardOne);
              cardPane.add("questionTwo", cardTwo);
              // end set-up card layout
              // set-up main pane
              // declare components
              msgout = new JTextArea( 8, 40 );
              buttonPanel commandButtons = new buttonPanel(screenvar, msgout);
              JPanel pane = new JPanel();
              pane.setLayout(new GridLayout(2, 4, 5, 15));   // row, col, hgap, vgap
              pane.setBorder(BorderFactory.createEmptyBorder(30, 20, 10, 30)); //top, left, bottom, right
              pane.add(cardPane);
                 pane.add( new JScrollPane(msgout));
                 pane.add(commandButtons);
              msgout.append("Successful");
              setContentPane(pane);
              setVisible(true);
    class updateDataFields implements ActionListener {     // 400
         private dataPanel abc;
         private JTextArea msg;
         int count = 0;
         public updateDataFields(dataPanel xyz, JTextArea msgout) {     // 100
              abc = xyz;
              msg = msgout;
         }     // 100
         public void actionPerformed(ActionEvent evt) {     // 200
              String command = evt.getActionCommand();
                   if (command.equals("TestMe")){     // 300
                        msg.append("\nSuccessful");
                        btnNextPressed();
                   }     // 300
         }     // 200
         private void btnNextPressed() {     // 500
    // problem here
              cardPane.next(cardTwo);
              }     // 500
    }     // 400
    class buttonPanel extends JPanel {     // 200   Similar to ButtonPanel in Duke's Bakery
         public buttonPanel(dataPanel xyz, JTextArea msgout) {     // 100
              GridLayout actionGrid = new GridLayout(1, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid);                    // different than panex.setLayout(xgrid);
              JButton buttonTest = new JButton("TestMe");
              buttonTest.setMnemonic('T');
              buttonTest.addActionListener( new updateDataFields( xyz, msgout ));
              add(buttonTest);
         }     // 100
    }     // 200
    class dataPanel extends JPanel {     // Similar to DataPanel in Duke's Bakery
         JLabel left1, left2, left3, right1, right2, right3;
         JTextField left01, left02, left03, right01, right02, right03;
        public dataPanel () {     // 1
              GridLayout grid = new GridLayout(3, 2, 5, 15); // row, col, hgap, vgap
              setLayout(grid);                    // different than panex.setLayout(xgrid);
              left1 = new JLabel("Left1");
              add(left1);
              left01 = new JTextField(0);
              add(left01);
              right1 = new JLabel("Right1");
              add(right1);
              right01 = new JTextField(0);
              add(right01);
    class cardTestOnePane extends JPanel {
         public cardTestOnePane() {
              GridLayout actionGrid1 = new GridLayout(2, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid1);
              JLabel cardNumberOne = new JLabel("Card Number One");
              JLabel cardNumberTwo = new JLabel("Card Number Two");
              add(cardNumberOne);
              add(cardNumberTwo);
    class cardTestTwoPane extends JPanel {
         public cardTestTwoPane() {
              GridLayout actionGrid1 = new GridLayout(2, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid1);
              JLabel cardNumberThree = new JLabel("Card Number Three");
              JLabel cardNumberFour = new JLabel("Card Number Four");
              add(cardNumberThree);
              add(cardNumberFour);
    }

    When importing files Lightroom states:
    The following files were not imported because they could not be read.
    IMG_5551.CR2
    When deleting files in Lightroom it states:
    The file named 'IMG_6191.jpg' could not be moved to the Trash folder
    When moving files Lightroom shows the following error:
    File could not be moved to the selected destination.
    EDIT: it is only happening in a single folder/location (with a lot of foto's and subfolders). The rest seems to be working correctly. Strange and irritating.

  • Use tab to advance through array of clusters?

    I have a control which is an array of clusters.  Is there any way to have the tab key advance through elements in the cluster, then proceed to the next array element at the end of the cluster?

    It's a wacky workaround but you could try using an event handler to capture the tab key and then programmatically tab through each element.  This forum post has a GREAT example posted on the second to last post that does exactly what you are looking for.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=380344&requireLogin=False 
    David_L | Certified LabVIEW Architect
    LabVIEW Tools Network | LabVIEW Tools Network Developer Center

  • Iterating through ArrayList backwards

    I'm trying to use a ListIterator to iterate through the contents of an ArrayList backwards, but I'm having trouble doing so. I can iterate forwards without a problem using .next() and .hasNext(), but I'm not sure how to start iterating at the "end" of the ArrayList.
    Thanks...

    Technically... wouldn't it have to be....
    ListIterator it = al.listIterator(al.size() - 1); // ?
    Also, another way to do it would be to reverse the List into another, although that could probably just be a waste of RAM...
    ListIterator it = Collections.reverse(al).listIterator();
    hi,
    you can do somthing like this
    ArrayList al = new ArrayList();
    // fill your list
    // now set up an iterator which goes backwards
    ListIterator it = al.listIterator(al.size());
    while (it.hasPrevious())
    Objekt obj = it.previous();
    }Timo

  • Moving RAID Array from old to new workstation

    I've completed building a new rig.  Win10 is working.  I have a RAID 0 array of 2-750GB drives in the old rig.  I've installed 2-1TB drives in the new rig.  Drive manager shows both old and new HD's but not as a single RAID array (RAID-OLD,
    and RAID-NEW, as I have named them during the BiOS RAID naming.  Could I have some guidance about this?  I also have the contents backed up on a USB-3 external drive, but would like to continue with both of the RAID arrays and not go through transferring
    data via USB.

    Hi CWO4 Mann
    For hardware, we need the driver to drive it works in Windows system. When you move your RAID to new system, ensure you have installed appropriate driver.
    I suggest you download the driver in Windows 10 Technical Preview, install it in Windows 8 compatibility mode to check if it works well.
    Alex Zhao
    TechNet Community Support

  • Looping through arrays

    Hello,
    I am developing a program which contains redundant code as it contains too many methods that loop through the same two dimensional array all the time.
    The reason why the code is redundant is because I need to perform a different action to different values in the array each time (depending on whether statement is true or false).
    What I want to try and do is create one single method which loops through the array and returns a boolean value.
    The method needs to take something like an if statement as a parameter so that I can stop searching through the array when the value of some element in array satisfies the if statement.
    How do I do this? How do I cut down the amount of code that searches through the same array all the time.
    Hope someone can understand
    Thanks

    Are you looking to do something like this?
    interface Predicate {
        boolean apply(int arg);
    class IsEven implements Predicate {
        public boolean apply(int arg) {
            return arg % 2 == 0;
    public class PredicateExample {
        public boolean searchMaxtrix(int[][] m, Predicate p) {
            for (int[] row : m)
                for(int x : row)
                    if (p.apply(x))
                        return true;
            return false;
    }

  • Looping through array

    If I declare an array such as the one below.
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        dbms_output.put_line(component_array(i));
      end loop;
    end;Is there a way to loop through only the existing binary_integer indeces? For example, if you execute the block above, you'll get an error because the loop iteration is hitting 12346 which of course doesn't exist. Other than the workaround below, is there another way using any type of array method?
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        begin
          dbms_output.put_line(component_array(i));
        exception
          when NO_DATA_FOUND then
            null;
        end;
      end loop;
    end;
    Thanks.

    Hi,
    Not to hijack this thread, but, since this is related to my answering OP's question, I am posting here.
    How come this code is erroring out?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12345) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;errors out with no_data_found, but, this doesn't ?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12344) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;notice the static numbers in the .exists parameter....

  • Searching through arrays part 3

       *  The moveTile method
       *  After the grid has been read and stored, the moveTile method
       *  takes in a single integer value that indicates a tile to move,
       *  and moves that tile into the blank tile's position, if it is a
       *  legal move. A move is only legal if the specified number exists
       *  in the grid, and if the specified tile's position is adjacent to
       *  the blank tile's position. The method returns a boolean value to
       *  indicate whether the move was made.
       * @param tileToMove The tile that is to be moved.
       * @return moveTile The boolean value which represents whether
       *                     or not the move was made.
      public boolean moveTile(int tileToMove){
        //set default boolean value to false
        boolean moveTile = false;
       //scans through the rows of the puzzle
        for(int scanRow=0;scanRow<grid.length;scanRow++){
          //scans through the columns of the puzzle
          for(int scanColumn=0;scanColumn<grid[0].length;scanColumn++){
           //scans through and checks if the desired tile exists
           //if it does exist, check if the '*' tile is beside it
          if(grid[scanRow][scanColumn]==tileToMove){
            //scans the tiles to the right of the tile being moved
            for(int besideRow=scanRow;besideRow<grid.length;besideRow++){
              //scans the tiles above the tile being moved
              for(int besideColumn = scanColumn;
                  besideColumn < grid[0].length;
                  besideColumn++){
                //scans the tile to the left of the tile being moved
                for(int besideRow2 = scanRow;
                    besideRow2 < grid.length && besideRow2 > 0;
                    besideRow2--){
                  //scans the tile under the tile being moved
                  for(int besideColumn2 = scanColumn;
                      besideColumn2 < grid[0].length && besideColumn2 > 0;
                      besideColumn2--){
                    //if the '*' tile is above or to the right of the tile
                    //being moved, then swap the files
                    if(grid[besideRow][besideColumn]== -1){
                      //create a temporary storage variable to store the
                      //value of the '*' tile
                      //if the '*' tile was above or to the right of the
                      //tile being moved
                      int temp;
                      //sets the value of the temporary storage variable
                      //to the value of the '*' tile
                      temp = grid[besideRow][besideColumn];
                      //sets the value of the '*' tile to the value of the
                      //tile being moved
                      grid[besideRow][besideColumn] = grid[scanRow][scanColumn];
                      //sets the value of the tile being moved to the value of
                      //the '*' tile
                      grid[scanRow][scanColumn] = temp;
                      //return the boolean value true since the tile was moved
                      moveTile = true;
                    //if the '*' tile is above or to the right of the tile
                    //being moved, then swap the files
                    if(grid[besideRow2][besideColumn2]== -1){
                      //create a temporary storage variable to store the
                      //value of the '*' tile
                      //if the '*' tile was above or to the right of the
                      //tile being moved
                      int temp2;
                      //sets the value of the temporary storage variable
                      //to the value of the '*' tile
                      temp2 = grid[besideRow2][besideColumn2];
                      //sets the value of the '*' tile to the value of the
                      //tile being moved
                      grid[besideRow2][besideColumn2] = grid[scanRow][scanColumn];
                      //sets the value of the tile being moved to the value of
                      //the '*' tile
                      grid[scanRow][scanColumn] = temp2;
                      //return the boolean value true since the tile was moved
                      moveTile = true;
        //returns the boolean true if the tile was moved and false if the tile
        //was not moved.
        //the default value is false
        return moveTile;
      }This is my code.... it works when the reference point of [0][0] is at the bottom left but when i changed my to string method to set the reference point of [0][0] at the top left.... it stopped swapping the tiles... it did give the correct boolean however

    This is my code.... ... and quite a lot of code I might say (nicely documented though). I
    strongly (sic) suggest that you strengthen your preconditions a bit, i.e.
    don't just fill your grid[][] but keep track of the blank position also (just two
    member variables).
    Since you're dealing with a two dimensional thing, both a row and
    column index are more appropriate than a single index number, although
    the latter can easily be converted to the former. Let's denote the index
    pair of the blank cell as bx, by.
    Here's a simple method that determines whether or not an (x,y) pair
    denotes a valid index pair in the grid:boolean isValid(int x, int y, char v) {
       try {
          return grid[x][y] == v;
       } catch (ArrayIndexOutOfBoundsException aioobe) {  }
       return false;
    }... this method not just tests the validity of the (x,y) index values: it also
    checks whether or not the (x,y) cell contains a 'v', whatever 'v' may be.
    Now suppose you want to move a tile at position (x,y) to the blank
    position (xb, yb). Here's how you swap those two positions:boolean swap(int x, int y) {
       if (isValid(x, y, grid[xb][yb]) {
          char tmp= grid[xb][yb];
          grid[xb][yb]= grid[x][y];
          grid[x][y]= tmp;
          xb= x; yb= y; // update the blank cell position
          return true;
       return false;
    }The four neighbours of a cell (x,y) are easily found and a bit of logic
    operator hacking yields:boolean move(int x, int y) {
       return swap(x-1, y) || swap(x+1, y) || swap(x, y-1) || swap(x, y+1);
    }Finally, if you want to move a cell (x,y) containing a star '*' to the blank
    cell, all you have to do is this:public boolean moveTile(int x, int y) {
       return isValid(x, y, '*') && move(x, y);
    }Note that this last method is just a bit of makeup. You could join it with
    the (non-public) 'move' method if you want.
    Also note that a bit of functional decomposition and factoring results in
    a lot less code.
    kind regards,
    Jos

  • Loop through Array structure - using xpath

    Hello,
    My BPEL process logic is as follows:
    a. Extract data into variable - receiveMessageInputVariable
    The variable 'receiveMessageInputVariable' in turn has data in array structure. (set of items)
    b. Transform the data to target structure
    c. Call target partner link to store extracted data into varaible 'ServiceInputVariable'
    The variable 'ServiceInputVariable' structure is similar to 'receiveMessageInputVariable'
    In the BPEL process 'at process' level - I have catch-all exception handler - which must send the list of 'items' which failed during a BPEL instance.
    i. If my email body has the following code as below:
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER')%>
    It successfully fetches only the first item_number record of the array structure. But does not fetch the other records in the array.
    ii. Similarly, I wish to print all the items (as received) to be available in the email body in the following pattern:
    <%"Record One-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[1]/ITEM_NUMBER')%>
    <%"<br/>"%>
    <%"Record Two-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[2]/ITEM_NUMBER')%>
    <%"Record Nth-"%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM[N]/ITEM_NUMBER')%>
    Please suggest a suitable syntax in my email body - which can loop through all itemline_item array and print all the item_numbers.
    (pseudo code below)
    for i in 1 .. ora:countNodes(bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER'))
    loop
    <%"Item Number-"%><%bpws:getVariableData('i')%>
    <%bpws:getVariableData('receiveMessageInputVariable','XXINV_ITEM_PAY_ROW_TYPE','/ns4:XXINV_ITEM_PAY_ROW_TYPE/ITEMLINE/ITEMLINE_ITEM/ITEM_NUMBER')%>
    end loop;
    Thanks,
    Santhosh

    Hi Santhosh
    Try with the following approach. It may work for you
    1. Create one XSD, for the HTML content
    <xsd:element name="HTML">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    2. Create one XSL, may be you have to do this manually, as JDev will not support HTML transformations. This XSL will map your input XML to an HTML format.
    3. Create one variable in BPEL of type in the above XSD
    4. Use assign activity to assign the XSL transformation to the variable defined in Step#3
    <from expression="ora:processXSLT('HTMLTransformation.xsl',bpws:getVariableData('Variable_Input',INPUT_TYPE'))"/>
    <to variable="invokeWriteHTMLService_Input" part="HTML" query="/ns6:HTML/ns6:C1"/>
    5. Copy the variable to the email body variable
    <copy>
    <from expression="bpws:getVariableData('invokeWriteHTMLService_Input','HTML','/ns6:HTML/ns6:C1')"/>
    <to variable="varNotificationReq" part="EmailPayload"
    query="/EmailPayload/ns8:Content/ns8:ContentBody"/>
    </copy>
    Basically, the above approach converts your input to a string value whose content is a complete HTML, and you will use only one value to assign to the email body.
    Note: Please change the Variable names/XPATH Expressions/XSL file name/element names etc according to your BPEL
    Hope this helps you
    Regards
    Ayon

  • Loop through arrays sequentially

    Hi!
    My goal is to send update parameter commands on the serial bus att different rates depending on which "priority" a certain parameter has.
    As input my idea was to use two text files, one containing a list of "high speed" = often updated parameters, and another with "low speed" = not so often updated parameters.
    I start with storing the parameter numbers in two arrays, a high speed array and a low speed array.
    My goal is to loop through the parameters in the high speed array and for each loop fetch one parameter name (number) from the low speed list and send that also. And so on.... continously.
    The serial-com part is OK it is just the variable fetching process that is a problem. The output from this vi should be a integer value updated at a specified frequency.
    Kind regards // Gustaf 

    Hi Gustaf,
    i tried to create an example for you, please see the attachment.
    Hope it helps.
    Mike
    Attachments:
    PriorityLoop_LV80.vi ‏18 KB

  • How do I lope through array, delete clip and remove from array

    I have a function that creates an instance of a movieClip and
    adds it to an array.
    In my gameloop I loop through the array and change some
    values. Now I want a cleanup function that loops through the array,
    and if the y value exceeds a certain value, I want to delete the
    clip instance and remove the record in the Array.
    Could someone please help me with the syntax for that? I will
    lay the code out below.
    Thankyou

    I still haven't gotten an answer on this one, and my client
    is starting to push me to fix the bug.
    I have created a number of instances of a movie clip, and I
    have also pushed references to each clip into an array.
    Then I loop through the array and do things.
    At some point I want to loop through the array and delete the
    original clips (removeChild).
    I don't know the syntax for that.
    for (var n:int = 0; n<myClipArray.length; n++){
    removeChild (myClipArray[n])
    // I WANT THE LINE ABOVE TO DELETE THE MOVIE CLIP
    I'd like to think there is some way to do that.

  • Traversing through Array

    I am trying to have an array of say size 30 and I want to traverse through it one by one and display the results digitally.
    I tried using INDEX ARRAY function but keeps on giving me a constant value and does not traverse through to the next element after displaying first one.
    Any advice please.

    Hi,
    I'm not sure I understand what function you tried to use. If it's the PropertyObject.GetArrayIndex, then the function will always return the array index string at a given offset in the array.
    The clasic way of traversing an array is to define an index for iterating, for example: Locals.index.
    Next insert a Label and a GoTo step.
    The GoTo step has to be configured as follows:
    1. Destination - 'Label'
    2. Precondition = Locals.index < GetNumElements(Locals.Array)
    3. PostExpression = Locals.index++
    In between the Label and GoTo step place your steps for accessing the array elements, based on the Locals.index.
    Hope this helps,
    Silvius
    Silvius Iancu

Maybe you are looking for