Is it possible to pause a for loop?

Hi all!
I wonder if it's possible in anyway, without using any
timelines, to "pause" a for loop.for a couple of second if some
statement returns true during the loop?
I.e. like this sketch up of a code example:
Thanks for any help :)

there is no way to pause or slow a for-loop or while-loop.
you would have to code for breaks in your for-loop(s) or use
setInterval() or an onEnterFrame loop to control the loops
execution after it starts.

Similar Messages

  • Is it possible to use a "for loop" structure to represent DAQ of 16 channels?

    Hi,
    I tried to search but I failed to find a similar problem so I am posting this problem here.
    I have a temperature DAQ board which has 16 channels, and I am using all 16 channels to record and monitor temperature data.
    When I writed blocks for all 16 channels, a mess was created (as you can see in my attached program). I have noticed that all the VIs for the 16 channels have similar structure, so I was thinking whether we can represent all 16 channels with a "for loop" strucutre with a pointer i scanning from i=1 to 16 as we usually do in Matlab or Fortran.
    For instance, we may try to simplify the code like:
    for i=1:1:16
         acquire data from channel i
         show data from channel i in X-Y graph
         write data from channel i to excel in every 10 seconds
    end  
    I could not do it myself because I cannot find a "pointer" to represent each channel.
    Does anyone know how to do this in LabVIEW? Thank you.
    It is said that it is best if we can put all of our code within the screen of a monitor we use by using subVIs to divide the code into many subroutines. But I found it quite difficult to do so as I have too many controls as inputs and indicators as outputs. Also, I use property node to read and write frequently, which make things harder....
    Attached code does not work as it requires the 9213 hardware, and for simplicity I deleted irrelavent modules. But if you need I can upload one that may work by modifying the read VI.
    Thank you.
    Attachments:
    ask for help.vi ‏132 KB

    Yup, instead of all these 1D arrays, use a single 2D array. Your code could be reduce to <10% of the current size. I am sure it would fit easily on a single screen.
    Also try to do some tutorial or take some courses. I realy don't think you are ready to tackle a system of this magnitude at this time.
    Your code is just peppered with very poor choices. Some things you apparently haven't figured out:
    index array is resizable. There is no need to create dozens of parallel instances, all wired to the same array and all with a unique index diagram constant. If you want all elements in order, the indices don't need to be wired at all.
    Replace all your value property nodes with local variables. Much more efficient. Then redesign the code so you don't even need most of the local variables.
    You can use built array to append elements to an existing array. Using "insert into array" is much more complicated an error prone.
    It is not a good idea to have deeply stacked while loops with the innermost loop having long delays and indeterminate stop conditions. That just gums up the gears.
    Learn about proper code architectures, state machines, etc.
    Get rid of that gigantic, all encompassing stacked sequence. I am sure you can find a better way to reset three booleans when the code is about to stop. In fact it is typically more reasonable to set things to a defined state when the program starts to avoid problems due to accidental value changes at edit time.
    Don't use hidden control/indicators as data storage and interloop communication via local variables. There are better ways.
    You can wire the reminder or Q&R directly to a case structure. No need for e.g. "=0".
    Don't use ambiguous labels, e.g.a boolean labeled "Dampers on or off". Nobody will be able to later figure out if TRUE corresponds to ON or OFF. Could it be that TRUE mean it is either ON or OFF and FALSE that it is in some imternediate position?
    LabVIEW Champion . Do more with less code and in less time .

  • Is it possible possible to exist from FOR loop while executing

    Hi
    Like break in C, is it any method available in LabVIEW to exist from a FOR LOOP while executing.
    thanks in advance

    No. You have to use a while loop.

  • For loop, possible to increment counter/exit loop?

    I would like to know if it is possible to exit a For loop. I know
    I can use a while loop but it would be nice to be able to
    increment the loop counter in a for loop. Is this possible?
    Thanks,
    Mike

    Jim,
    OK, that clears it up. Coming from VB I'm still figuring out the
    differences.
    Thanks,
    Mike
    James Morrison/Joan Lester wrote:
    >
    > Also remember you can make while loops auto index. Right pop on the tunnel
    > and enable this and the loop will then act more like a for loop.
    >
    > Jim
    >
    > "Kevin B. Kent" wrote:
    >
    > > Mike Scirocco wrote:
    > >
    > > > I would like to know if it is possible to exit a For loop. I know
    > > > I can use a while loop but it would be nice to be able to
    > > > increment the loop counter in a for loop. Is this possible?
    > > >
    > > > Thanks,
    > > > Mike
    > >
    > > No sorry it is not possible.
    > > If you need this kind of functionality you will have to use a while loop.
    > > You can then setup all manner of conditions to exit the lo
    op.
    > > Be aware that the loop will always run at least ONCE.
    > >
    > > A for loop will run X number of times. This is determined either
    > > at compile time (if the count is hard coded) or at run time
    > > (if you use auto-indexing, or the count is a variable).
    > >
    > > Kevin Kent

  • Using a For loop to call one array element at a time

    I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.
    Adam

    adamoutlaw wrote:
    Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
    I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
    Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
    Message Edited by altenbach on 08-02-2007 07:14 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Indexing.png ‏4 KB

  • Statechart intstances in for loop

    Is it possible to use a FOR loop to create multiple instances of an asynchronous statechart?
    See attached code, it works fine with only one instance in the array, but as soon as one expands the array to two instances, error 1100 occurs.
    Thanks in advance... 
    Attachments:
    statechart in for loop.zip ‏293 KB
    statechart in for loop.jpg ‏102 KB

    Here is a quick and dirty example.
    For this example, I chose to use a synchronous statechart because it actually translates much more naturally to the idea of spawning several instances of a statechart and then talking to the instances. You can use an asynchronous statechart as well, but it makes the spawning and talking processes significantly more complicated/involved (I can talk more about that in another post if anyone is really interested). Anyways,
    In the attached files, spawner.vi is the top-level VI. It begins by creating a number of instances of a simple statechart. The statechart doesn't do much. It just throws up a one button dialog with a particular string when a certain transition is taken.
    With the instances spawned, we then enter into a while loop with event structure, which waits for user input to cause us to talk to one of the statecharts. You can pick which statechart to talk to (numbers 0,1,... n-1, if you spawned n statechart instances). When you press the talk button, we will send a "SayHi" trigger to that statechart. It will take one step and throw a dialog telling you hi and what statechart number you are talking to (to prove you are actually talking to different statecharts).
    Hope that helps. Let me know if any of it isn't clear. 
    Attachments:
    spawn_example.zip ‏240 KB

  • Stopping for loop

    Hello
    I’m trying to stop a for loop of a subVI while it is still running. In the example you can see my problem. When I run the main VI the loop begins. When I press the stop button (in the main VI) the loop first finishes and after that the VI stops. Is it possible to program that when I push the button the VI immediately stops?
    Thank you in advance
    Attachments:
    Try.llb ‏35 KB

    becktho a écrit:
    Did you really stop a for loop? If so - could you attach the library as LV7.0? I'm wondering how you could have accomplished that.
    Sorry to disapoint you Becktho, but the loop was a while loop. And anyway, I would have replaced it !
    I agree with you, the possibility to leave a for loop would be of interest, although a while loop (actually a repeat-until loop) is easy to use. But the diagram could be simplified. Imagine : right-click the loop border, and select "create conditionnal exit", just bellow "add shift register"
    On another hand, having only two types (actually 3 with the timed loop) of loop structures is also quite simple. Have you noticed how beginners are confused by the number of different wire types ?
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • For loop pause till event occurs

    I'd like to know if it's possible pausing for loop in a fixed step till en event occurs.
    I need to use for loop index to indexing some vector's data, but the steps in for loop must be exectuted only if  precise condition occurs.
    thank you very much for possible solutions
    Francesco

    Without seeing any code, it is hard to recommend what to do.
    You probably want a State Machine architecture so that you can stay in a certain state of a while loop, then move on to the next step (state) when your condition is met.
    You could also use event structures.  You could also use notifiers or occurrences to hold the execution of your loop until the notifier is written to or occurrence executed in a parallel loop of your code.

  • While loop in a for loop,Is it possible?

    Is It possible to call a while loop a particular number of time's using a for loop.
    for example :
    for(.....){
    while(true)
    Is this technically possible?
    Thanks,

    Hans9777 wrote:
    Based on the code you wrote , the program will enter the for loop and then the while loop . It will never exit the while loop as while(true) means loop infinite times. normally while do-while and for loop can be immplemted for the same function therefore they are rarely used together.Obviously his code only showed the loop structures themselves with no loop bodies. Supposedly there may be a 'break' in the while loop somewhere, so it is not necessarily an infinite loop.
    And your remark about them rarely being used together is nonsense. Loops within loops are written for legitimate logic purposes all the time, regardless of what kind of loops they are.

  • How to pause and stop two "for loops" in an event

    Hi
    The main menu runs first and then goes to reading menu. After "Start Reading" button is pressed, the reading process will take readings.
    1) During reading process, if the "Pause Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters do not reset. After the "Start Reading" button is pressed, the two "for loops" will continue to run.
    2) During reading process, if the "Stop Reading" button is pressed, I want that the two "for loops" are stopped and the two "for loop" counters are reset. After the "Start Reading" button is pressed, the two "for loops" will run again.
    The attached two VIs are simplified my real application. Any help will be appreciated.
    Thanks
    Steve
    Attachments:
    Main Menu Test.vi ‏9 KB
    Reading Menu Test.vi ‏23 KB

    You can't have those loops inside of the event structure.  Currently, when you press the start button, the reading has to finish before the event case finishes.  This will prevent the stop can cancel buttons from being processed by the event structure.
    You need another loop that can recieve commands from the event loop.  Look up the Queued Message Handler.  That should get you a good start on the command process.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is it possible to put property node inside for loop?

    I have created three separate property nodes (plot color) for my 3 XY graphs.
    Is it possible to have one property node, say plot_color_i and put this inside the for loop where i runs from 1 to N,
    where plot_color_1 would update XY Graph 1, plot_color_2 would update XY Graph 2, etc.?
    See the attached VI.
    Solved!
    Go to Solution.
    Attachments:
    XY Plot Example.vi ‏18 KB

    Yes.  Create an array of references of the XY graphs and have that auto-index into the property node in the For Loop
    Attachments:
    XYPlotExampleMOD.vi ‏18 KB

  • The demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.

    the demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.
    your recommended second option that i could add true/false case.
    this true/false case must be inside the for loop or outside the for loop?if this case is inside the for
    loop, how can i send stop command from outer while
    loop?
    more over do you have any example for this please?
    thanks"

    You can execute a fixed number of iterations using a while loop by comparing the iteration count to the number of iterations you want and wiring the output of that comparison (e.g. Less Than or Equal To) to the continue (or stop) terminal of your while loop. Which comparison you use depends on personal preference, where you wire the desired count and the interation count, and whether you're using the while loop as Continue if True or Stop if True.
    Ben gave you step-by-step instructions in response to your previous question. Look here for Ben's response.
    Ben's response looks pretty good and detailed to me. It certa
    inly deserved better than a 1-star rating.

  • My for loop pauses after completion of the prescribed number of loops.

    I've created a FOR loop to alternate the value of an analog output between two setpoints. Since there are only 2 setpoints there need only be 2 complete 'loops'. After these two loops are complete the program pauses before continuing restarting the loop. I used the FOR loop instead of a WHILE loop because I use the value of the loop number to change the value of the output.

    Maybe you are initializing DAQ before the For Loop executes or you have a Wait timer outside of your For Loop.

  • Is it possible to set multiple textfield value with a for=loop

    JTextField W1HourTF=new JTextField(8);
    JTextField W2HourTF=new JTextField(8);
    JTextField W3HourTF=new JTextField(8);
    JTextField W4HourTF=new JTextField(8);
    I have created the above 4 textfields, I want to set all the text field editable using a for loop.
    Is there any method which can do it? Example :
    for (i=0,i<=4,i++)
    WHourTF.setEditable(true); // where i is based on the loop time

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.border.*;
    class JTEXTFIELD extends JFrame
         JTextField [] jTextFieldArray = {jTextField1, jTextField1, jTextField2, jTextField3};
    ========================================================================
    How come I get error :
    JTEXTFIELD.java:9: cannot resolve symbol
    symbol : variable jTextField1
    location: class JTEXTFIELD
    JTextField [] jTextFieldArray = {jTextField1, jTextField1, jTextField2,
    jTextField3};

  • How to Play/Pause All for Adobe Air Application using AS3 in Flash CS4?

    I am new to Flash and I'm creating an educational application in AS3 in Flash CS4 for Adobe Air. I want to use buttons to play and pause all content (movieclips AND sound).
    I have created play and pause buttons that worked by switching the frame rate between 0 and 20, unfortunately I've realised that it's never really 0fps but rather 0.01fps and so it continues playing, albeit very very slowly. Also this doesn't affect the audio; I have set sound files to Stream which are synced to movieclips on their timelines, but even when the application is set to 0fps the audio continues.
    Since I have various levels with numerous movieclips each with synced audio, what i'd like is to be able to do is pause absolutely everything within each movieclip with one button and to be able to resume from the same place using another button. Is this possible? If not, is there a global function to pause/resume the entire application/program?
    Thanks in advance for your help!

    Its possible but you would need to tell each movieclip and audioclip to play/pause. You can create a for loop inside your mouse event function to find each movieclip and pause/play its timeline and a separate for loop for audio clips. Also instead of setting fame rate to 0 for pause just use a stop() command.

Maybe you are looking for

  • Amazing lack of customer service

    OK, first complaint: - It would certainly be nice to be able to talk to a real human who cares about customer service complaints.  The phone support really isn't empowered to do much, and there's no option after that...except posting to some forum. I

  • How do I export a small section of a large complex illustrator graphic?

    I have a large complex map in an illustrator file and I need to export smaller sections of the map for other uses. When I use artboards, the files still retain ALL of the information. I just want the portion that is on the artboard and I want it as a

  • Finding a matching name in an ArrayList

    I am trying t traverse an array list and find a matching name but it is not working....can anyone point me in the right direction?      for(int i=0;i<temp.size();i++)                     Employee p=(Employee)temp.get(i);                     if(p.getL

  • BT Wifi Promotions

    I have just had an email telling me how wonderful BT Wi-Fi is. Nothing has changed since my previous correspondence with them on this - it is absolute rubbish and is not of any use when out and about. Standing next new green BT Infinity cabinets I ca

  • How to authorize QT Pro in v. 6...?

    This is an unusual question about backwards compatibility... I have a Quicktime Pro 7 key for OS X on my iBook G4 and it works great, no problems there. But I also have a G4 running OS 9.2.2 (only) in my studio with QT 6.0.3, Standard Edition. It wou