For loop doesn't stop at any point

public function getLabel(jail):String
       var frameLabel:String = mc.currentLabel;
      for(var i=0; i<jail.currentLabels.length; i++)
             if(jail.currentLabel == jail.currentLabels[i].name)
                   trace(jail.currentLabels[i].name);
                 if(mc.currentLabels[i] != undefined)
                         frameLabel = mc.currentLabels[i+1].name;
                  else
                        frameLabel = mc.currentLabel;
       return frameLabel;

if you want to stop the loop if you get a match, use:
public function getLabel(jail):String
       var frameLabel:String = mc.currentLabel;
      for(var i=0; i<jail.currentLabels.length; i++)
             if(jail.currentLabel == jail.currentLabels[i].name)
                   trace(jail.currentLabels[i].name);
                 if(mc.currentLabels[i] != undefined)
                         frameLabel = mc.currentLabels[i+1].name;
                  else
                        frameLabel = mc.currentLabel;
       return frameLabel;
       return frameLabel;

Similar Messages

  • My article keeps showing the spinning graphic saying it is still updating. It doesn't stop. Any idea

    My article keeps showing the spinning graphic saying it is still updating. It doesn't stop. Any ideas?
    This is happening in the Folio builder panel

    This happening to me as well. I have 13 articles and the last one keeps spinning. I really don't want to have to delete the entire folio and start again...

  • Java - sleep in a for loop doesn't work (as desired)

    Hey all,
    I'm trying to get a draw animation when the mouse is released (after dragging an object to a set area on the screen) - hence I'm trying to do this via a for loop with a small sleep() delay. However it isn't working. The delay is there, but nothing changes until the end of the for loop and then you only see the final repaint() [i.e. instead of each iteration in the for loop]:
    // This program is concerned with this and the mouseDragged methods
         public void mouseReleased(MouseEvent e)
              for( int c = 0; c < xButton.length; c++)
                   if( xButton[c] >= xRandWeight && xButton[c] <= (xRandWeight+50) && yButton[c] >= yRandWeight && yButton[c] <= (yRandWeight+50) )
                        // Have an animation for the scales re-adjusting
                        if( c == 0 )
                             currWeight = (int)(scales.getWeight2());
                             desiredWeight = Integer.parseInt(b1.getLabel());
                             if( desiredWeight >= currWeight )
                                  // More efficient than putting this subtraction straight into for loop
                                  difference = desiredWeight - currWeight;
                                  for( int count = 1 ; count <= difference ; count++ )
                                       scales.setWeight2(currWeight+count);
                                       repaint();
                                       try
                                            Thread.currentThread().sleep(100);
                                       catch (InterruptedException in)
                                            in.printStackTrace();
                             else
                                  difference = currWeight - desiredWeight;
                                  for( int count = 1 ; count <= difference ; count++ )
                                       scales.setWeight2(currWeight-count);
                                       repaint();
         }Any ideas on how to fix this/meet the goal would be greatly appreciated :)
    Thanks,
    Tristan Perry
    Edited by: TristanPerry on Nov 16, 2008 12:36 PM

    My program isn't being written in SWINGFirst, it's Swing, not SWING. It's not an acronym.
    Perhaps you would like to tell us which windowing toolkit you are using, so that you can get better responses. Or is that a closely guarded secret? <sarcasm/>
    I'm very new to JavaSo ditch the GUI stuff and get a foundation first.
    db

  • Using CONNECT BY LEVEL with For Loop Doesn't Work

    The procedure listed below inserts only one record in table whereas i need 10 records to be inserted in table.
    this is just a test procedure..
    CREATE OR REPLACE PROCEDURE P_TEST
    AS
    BEGIN
    FOR I IN (SELECT LEVEL num FROM dual CONNECT BY LEVEL <= 10)
    LOOP
    INSERT INTO TEMP_VMS VALUES(I.num);
    END LOOP;
    END;
    END;
    /

    Salim Chelabi  wrote:
    Or with 9ir2
    INSERT INTO TEMP_VMS
    SELECT COLUMN_VALUE
    FROM TABLE (SYS.dbms_debug_vc2coll (24, 34, 25));
    SELECT *
    FROM TABLE (SYS.dbms_debug_vc2coll (24, 34, 25));
    COLUMN_VALUE                                                                   
    24                                                                             
    34                                                                             
    25                                                                             
    3 rows selected.
    http://laurentschneider.com/wordpress/2007/12/predefined-collections.html
    That doesn't split strings...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'a,b,c,d,e' str from dual)
      2  --
      3  SELECT *
      4*   FROM t, TABLE (SYS.dbms_debug_vc2coll (t.str))
    SQL> /
    STR
    COLUMN_VALUE
    a,b,c,d,e
    a,b,c,d,e... it only defines a table of values

  • After I put an inner for loop,i don't get any output!

    Hello,
    I have an RTF which does not show the output properly. I had a for-each@section, then i put another for-each to repeat the block of data twice
    The code is as follows:
    *<?for-each@section: Books_S1/Category_S2_Group/On_Rental_S3?>*
    <?Fax_Number_ID10?>
    <?for-each:xdoxslt:foreach_number($_XDOCTX,1,2,1)?>
    Value does not display here!!!!!
    <?Order_Number_DOCO_ID20?>
    <?end for?>
    *<?end for-each?>*
    Please help me on this issue, i must display the value in the inner loop. I think it has lost the data (+for-each@section: Books_S1/Category_S2_Group/On_Rental_S3+) when it steps into the inner loop
    Edited by: Lovvyrules on Dec 2, 2010 10:08 AM

    It should be the other way.
    Can you try this out.
    <?for-each@section:xdoxslt:foreach_number($_XDOCTX,1,2,1)?>
    <?for-each: Books_S1/Category_S2_Group/On_Rental_S3?>
    <?Order_Number_DOCO_ID20?>
    <?end for-each?>
    <?end for-each?>
    Also check the link for an example http://winrichman.blogspot.com/2008/09/multiple-copies-in-bi-publisher.html

  • While loop doesn't stop until 2 more clicks

    I have to say I am really not familiar with LV at all, but Im learning.
    So, why is that after I clicked stop bottom, I had to click my OK button twice, then my program stopped. Why it can't stop immediately?
    Besides, if I want to some the dice result by array, which wire am I missing?
    Thank you!
    Solved!
    Go to Solution.
    Attachments:
    dice.vi ‏15 KB

    Hi RawtoLV,
    You have a while loop within a while loop. When you run the other while loop stops when you pressed the stop button, the inner while loop still runs. Since your OK button is using Latch when released, what i noticed is that when you pressed that OK button, it quickly switched to from true to false which didn't stop that while loop operation (could be due to the wait). May I ask what are you actually doing with the sequence structure?
    I would suggest using event structure instead (http://zone.ni.com/reference/en-XX/help/371361K-01/glang/event_structure/):
    here some more info on event structure:
    http://www.ni.com/white-paper/3331/en/
    http://www.youtube.com/watch?v=8eO64fo3Pho
    Warmest regards,
    Lennard.C
    Learning new things everyday...

  • Is there any point in having an ORDER BY clause within a FOR LOOPs counter?

    DB Version:10.2.0.1.0
    I need to loop through empno's using a FOR loop. But is there any point in having an Order by clause within SQL as shown below. This only degrades the performance because of the unnecessary sorting by the ORDER BY clause. Right?
    begin
    FOR i IN (select empno from emp ORDER BY sal ASC) LOOP 
        curr_stat_id := i.empno +p_gennum;
    .

    First question you should ask to your self is
    "Do i need a FOR LOOP. Cant i do it in a straight SQL"
    If the answer is NO (Which is not in several cases) then the next question is.
    "What is my requirement"
    Having an order by in the Select is totally pertained to your requirement. If your requirement
    says you should loop through the employee based on there salary for lowest to highest then yes you
    need an order by.
    So more than performance point of view its requirement point of you. But if you are more concern about
    performance you will first ask to your self
    "Do i need a FOR LOOP. Cant i do it in a straight SQL"
    Thanks,
    Karthick.

  • Stopping a For Loop, part 2

    Hello. Thank you everyone for your help, getting to this point. I asked for help to create a stop condition, while a For Loop is running. I was given many ideas and selected the one that used local variables. It works well however, if I am in the "Test in progress" state, in the first For Loop, and the "Stop" button is selected from the front panel, when it stops the Vi, it sends the value "5" to the second For Loop before going to the "End" state, which puts it to "0", then stops the Vi. What this Vi is doing is feeding 0-200VDC signal to an eddy current sensor, then it feeds 200-0VDC going the other direction. I have tried sequencing, putting in timers and a few other goofy things but I can not get the Vi to stop in the first For Loop, without the Vi performing the initial "5" to the second For Loop. Someone had mentioned using an event handler, in my previous post. I practiced for quite some time, trying to understand how to use an event handler but am not much the wiser. Any and all input would be greatly appreciated.

    altenbach wrote:
    ceilingwalker wrote:
    You are autoindexing way too many thing between the two FOR loops I was doing this to create a data dependency, at least that was my thought process behind it. As far as the physical channels and VISA refnums, I did it this way so I didn't create more controls for the front panel. Being my first project, I am very certain my logic is flawed, this is why I like posting here and getting feedback from
     You have many visa sessions that (hopefully) never change during the execution of the loops, so why woold you turn them into an array of 11 identical elements just to autoidex them out again at the next loop. Change the tunnels to no autoindexing and things would look cleaner. Why are these session controls inside the loop? Are you expect them to be changeable during loop execution or would that screw up the results?
    Wounld't it be easier to simply create an up&down ramp once and use a single FOR loop, autoindexing on the ramp? You have way too much duplicate code!!!
     If you don't want the second loop to run when the first one is ended prematurely with the stop button, put it in a case structure I tried a Case structure for the second For Loop. I couldn't find a way to change conditions that didn't affect the Vi's overall performance.
    Then show us what you tried! That should be trivial to implement. Why would a case structure affect performance? Makes no sense!
    Why would a case structure affect performance? Makes no sense! I used a boolean operator to change the state. When I used a false, it worked for that problem but shut down my Vi before the second For Loop. 
    Wounld't it be easier to simply create an up&down ramp once and use a single FOR loop, autoindexing on the ramp? You have way too much duplicate code!!!  I tried using one For Loop to begin with but because I had to ramp up, then ramp down, I couldn't figure out how to use just one. I needed an Add function for the ramp up and a Subtract function for the ramp down.
    Why are these session controls inside the loop? Are you expect them to be changeable during loop execution or would that screw up the results? No Sir, the values are not changed during operation. I did this because I wanted it to display the data on the front panel, during operation of the Vi. For display only.
     

  • How to create for loop USING a while loop

    Hi, I would like make a for loop inside of a while loop because I want to control the i count of the loop, and overall, more control over the loop. From what I understand, labVIEW's for loop doesn't let me change where the i count starts. It always start at i=0, and what I want to do is be able to jump to specific loop iterations and then continue from there.
    Thank you.

    That is not the same as the earlier examples.
    If you want 10 counts and start at 0, then the stop terminal will stop after 10 times.  Just like you get when you wire 10 into the N terminal and don't have a conditional loop.
    If your start value is larger, let's say 9, then your loop will only run 1 time because i=0 on first iteration + 1+ 9 (start value).  0 + 1 +9 = 10.
    If your start value is larger than 10, then it will run 10 times again because on the intial iteration the result of your comparison is already greater than 10 and won't stop, and will never be equal on later iterations.
    So your example does not even give consistent results depending on the value you use as the start value.
    (Just to note, my earlier examples may not all be identical results as I didn't try to verify all the stop conditions nor the array that is output by the ramp function.  I could be off by one iteration here or there.  But they should be good enough to point out distinctive ways to accomplish what the OP asked for.)

  • Node removing in a Tree, for loop, and Enumeration

    Hi there
    it should be pretty easy, however i'm stuck with this code:
    public void supprNode(DefaultMutableTreeNode node){
    for(en = node.preorderEnumeration();e.hasMoreElements();){
    DefaultMutableTreeNode tmpNode= (DefaultMutableTreeNode) en.nexElement();
    if (tmpNode instanceof myderivedNodeClass)
        tmpNode.doSomething();
    if(!tmpNode.isRoot())
        removeNodeFromParent(tmpNode);
    }The problem is, the for loop doesn't traverse all the elements. That's if i call removeNodeFromParent. Is the enumeration updated twice?
    ie if my tree is
    root
    -1
    -2
    -3after the call of supprNode(root) i get:
    root
    -2And i really don't understand why.

    Hi!
    If you look at the apidoc of DefaultMutableTreeNode.preorderEnumeration() you will see following text:
    * Modifying the tree by inserting, removing, or moving a node invalidates
    * any enumerations created before the modification.
    So you should copy the elements of the enumeration in a separate list and iterate then over this list!
    With kind regard,
    Mathias

  • Getting the label of a JButton in a for loop

    hi,
    I doing a project for my course at the minute and im in need of a bit of help. I have set up 1-d array of buttons and i have layed them out using a for loop. I have also added an annoymous action listener to each button in the loop. It looks something lke this:
    b = new JButton[43];
    for (int i=1; i<43; i++)
    b[i] = new JButton(" ");
    b.addActionListener(
    new ActionListener()
    public void actionPerformed(ActionEvent e)
              System.out.println("..........");
    }); // addActionListener
    } // for
    I want the "System.out.println( ..." line, to print out the "i" number of the button that was pressed but i cannot figure out how to do it. I cannot put "System.out.println(" "+i);" as it wont recognise i as it is not inside the for loop. Does anyone have any suggestions?
    Thanks!!

    class ButtonExample extends JFrame implements ActionListener{The OP wanted to have anonymous listeners, not a subclassed JFrame
    listening to the buttons. I don't know if the following is the best design,
    since the poster has revealed so little, but here is how to pass the
    loop index to an anonymous class.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ButtonExample {
        private JButton[] buttons = new JButton[24];
        public JPanel createGUI() {
            JPanel gui = new JPanel(new GridLayout(6,  4));
            for(int i=0; i<buttons.length; i++) {
                final int ii = i; //!! !
                buttons[i] = new JButton("button #" + i);
                buttons.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent evt) {
    System.out.println("number " + ii);
    gui.add(buttons[i]);
    return gui;
    public static void main(String[] args) {
    ButtonExample app = new ButtonExample();
    JPanel gui = app.createGUI();
    JFrame f = new JFrame("ButtonExample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(gui);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);

  • For loop in a recursion

    I am trying to write a program in which a series of numbers are generated by a recursive function based on strict number rules... such as the first number is always 94 and it can be only followed by 94,95,96,97, etc... I would like to get some help because I am doing a for loop in my recursive method, however the method just ends after one iteration and only display the first serie of numbers. I don't understand what I did wrong, so if someone could fix that part for me or tell me what is going wrong, I will appreciate a lot... Here is the code:
    public class StringSeries {
         static int nextInteger;
         static int lastInteger;
         static String numberWord = "";
         public static int[] lastNumber(int k, int nextK){
              if (k==94){
                   if (nextK==94){
                        int numEnd9494[]={97};
                        return numEnd9494;
                   if (nextK==95){
                        int numEnd9495[]={97,98};
                        return numEnd9495;
                   if (nextK==96){
                        int numEnd9496[]={97,98,99};
                        return numEnd9496;
                   if (nextK==97){
                        int numEnd9497[]={97,98,99};
                        return numEnd9497;
                   if (nextK==98){
                        int numEnd9498[]={98,99};
                        return numEnd9498;
                   if (nextK==99){
                        int numEnd9499[]={99};
                        return numEnd9499;
              return null;
         public static int[] nextNumber(int n){
              if(n==94){
                   int numArray94[] = {94,95,96,97};
                   return numArray94;
              if(n==95) {
                   int numArray95[] = {95,96,97,98};
                   return numArray95;
              if(n==96) {
                   int numArray96[] = {96,97,98,99};
                   return numArray96;
              if(n==97) {
                   int numArray97[] = {97,98,99};
                   return numArray97;
              if(n==98){
                   int numArray98[] = {98,99};
                   return numArray98;
              if(n==99){
                   int numArray99[] = {99};
                   return numArray99;
              else
                   return null;
         // When this method is called out for the first time, "nextInt" must be the same as "firstInt"
         public static String generateSequence(int firstInt, int nextInt, int seqLength){
              if (seqLength==1) {
                   for (int i=0; i<(lastNumber(firstInt,nextInt)).length; i++) {
                             lastInteger = (lastNumber(firstInt,nextInt));
                             numberWord = "" + lastInteger;
                             return numberWord;
              else {
                        for (int j=0; j <(nextNumber(nextInt)).length; j++){
                             nextInteger = (nextNumber(nextInt))[j];
                             numberWord = nextInteger + " " + generateSequence(firstInt,nextInteger,seqLength-1);
                             return numberWord;
                   return null; //I don't understand why I have to put this line or else I get a compiler error     
         } // End of method
    } // End of class

    I made that one change, but then I just get the last serie of numbers.... Is there like some small mistake with my for loop besides the one you had pointed out?
    // When this method is called out for the first time, "nextInt" must be the same as "firstInt"
         public static String generateSequence(int firstInt, int nextInt, int seqLength){
              if (seqLength==1) {
                   for (int i=0; i<(lastNumber(firstInt,nextInt)).length; i++) {
                             lastInteger = (lastNumber(firstInt,nextInt));
                             numberWord = "" + lastInteger;
    return numberWord;
              else {
                        for (int j=0; j <(nextNumber(nextInt)).length; j++){
                             nextInteger = (nextNumber(nextInt))[j];
                             numberWord = nextInteger + " " + generateSequence(firstInt,nextInteger,seqLength-1);
    return numberWord;
         } // End of method                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • For Loop Parallelization

    Hi All,
    I need to run an algorithm on 12 images. One way would be to run it in a for loop sequentially. However this will take a long execution time.
    So after searching a little I  found that an alternative to speed up execution is by the using parallelized for loop- as seen here. 
    I have 1 subvi(lets call it-mytry1.vi) which is present inside the parallel loop. mytry1.vi is preallocated re-entrant.
    mytry1.vi uses functions from image processing toolkit and contains shift registers. All the library functions are also made re-entrant(by default they are shared and not pre-allocated).
    My PC config is intel dual core 2.0 GHz and I'm using LabVIEW 2013.
    When I use Find Parallelizable loops (Tools->>profile->>) to see whether mytry1.vi is parallelizable or not, I get the following result
    for loop 1 : Possibly not parallelizable - One or more nodes in the For Loop may have side effects. 
    I ignore this and make it a Parallelized for loop(this does not throw any error).
    When I run the vi, it is behaving as a sequential for loop rather that parallelized.
    Why does this happen? Is it because of the use of shift registers?? 
    Regards
    Aveo 

    Shift Registers themselves would not cause a problem.  Unitialized Shift Registers, however, could cause all kinds of interesting issues with state.  But that has nothing to do with your loops behaving serially.
    I'm thinking it could potentially be the DLLs the toolkit calls are not thread safe.  They could potentially be set to run in the UI thread, which would cause the serial processing you are seeing.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Illegal start of type error when adding for loop to applet

    I have typed the following applet to print a horizontal row of stars with the length entered by the user (i.e. user enters 4 and applet prints out 4 stars in a row). Here is my code:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
           String input = "";
            int number;
         public void init()
              input = JOptionPane.showInputDialog ( null,
              "Enter a number\nbetween 1 and 30:" );
              number = Integer.parseInt( input );
         public void paint ( Graphics g )
              for ( int counter = 1; counter <= number; counter++ )
                                    System.out.print( "*" );
               System.out.println();
    };Now I am trying to make it do this 5 times, so it seems like just surrounding the init and paint methods in a for loop (i.e. for ( int i=1; i <= 5; i++ ) ) would do the trick but when I do that I get an illegal start of type error when trying to compile. Does anyone know why this error would show up. The most common reply to questions of this sort seems to be to check the closing braces but I have checked very carefully after adding the for loop and don't see any problems with mismatched braces. Could you please help me get on the right track as to how I can make this applet print a horizontal row of stars five times? All help is appreciated.

    Hello JTMOBOP:
    You were correct in figuring that I was trying to get the applet to print five rows of stars of different length according to five different inputs from the user. I tried your suggestions, and the code now does compile and run, but it still does not run properly (i.e. only asks user once for input and displays row of stars but does not show an input dialog again). Here is the code I have retyped:
    import java.awt.Graphics;
    import javax.swing.*;
    public class Histograms extends JApplet
       String input = "";
       int[] number = new int[5];
       public void init()
          for ( int i = 0; i < 5; i++ )
             input = JOptionPane.showInputDialog ( null,
                "Enter a number\nbetween 1 and 30:" );
             number[i] = Integer.parseInt( input );
       public void paint ( Graphics g )
          for ( int i = 0; i < 5; i++ )
             for ( int myNumber = 0; myNumber <= number; myNumber++ )
    System.out.print( "*" );
    System.out.println();
    Any ideas what's going on here?
    Also, your comments about not being able to loop a method make sense. Thank you for the input so far.

  • For-looping Through All textFrames (cs4 jsx)

    var docRef = app.activeDocument;
    for (var num=0; num<docRef.textFrame.length; num++){
         alert( docRef.textFrames[num] );
    I would like to for through all of the text frames in a document to experiment with what properties return what information.  I have a simple test document with like three different text frames, and I want to collect info on each one.  This for loop doesn't seem to work though, and I can't quite wrap my head around how the textFrame and textFrames objects work.
    Thanks for the assistance!

    textFrames = a collection of textFrames
    textFrame = a single textFrame, for example textFrames[1] refers to the second textFrame
    try this
    var docRef = app.activeDocument;
    for (var num=0; num<docRef.textFrames.length; num++){ // you were missing an s
         alert( docRef.textFrames[num]); // returns the object itself
         alert( docRef.textFrames[num].contents ); // returns a property (contents) of the object

Maybe you are looking for

  • Not able to get the details of messages in BizTalk Server

    I have Biztalk Server 2010 setup. I have created a sample message and tried to check the application by sending the message(using FILE protocol). I am getting the message at the send port successfully but I can't find any entry in the database for an

  • Binding UI element in a table

    Hi I have a table UI based on a context mapped to Adaptive RFC Model. I would like to add another column with buttons and to be able to manipulate their 'enable' property based on values in the table. I created new context node with attribute value o

  • BootCamp Killed my MBP Display

    Hello, tl;dr : Bootcamp installation has turned off [destroyed?] my display adapter on my MBP. How do I turn my display back on using only network file access (or ssh if I can somehow turn it on provided systemwide network files access)? I'm desperat

  • No v9 properties toolbar access except in last document opened

    Has anyone else noticed this in v9.0 or 9.1 of acrobat? You want to change the properties of an object such as the text format in a comment/markup text box and, even though you can select the text, "No current selection" is reported where the propert

  • SOD and Risks

    I was going through the SOD listed at http://www.*********************/sox_sod/sod_matrix.htm and I was wondering why the following are in conflicts: Conflicts by business process 1) AP Invoice Verification and AP Payment Runs/ Clearing 2) Customer M