For Loop Inside A For Loop

Is it possible to execute all the iterations of the inside for loop for each iteration of the outside for loop? I have attached a screenshot of my program if it helps. If it is possible could you tell me how to do it plz?
Solved!
Go to Solution.
Attachments:
Capture.PNG ‏53 KB

One thought I have is that I think you want those feedback nodes reinitializing for each iteration of the outter loop.  Personally, I would change them to be shift registers (it would clean up your diagram a little bit).
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Usage of for-each loop inside another for-each loop

    Hi All,
    I have tried using a for-each loop inside another for-each loop as given below.
    <?for-each:G_1?>
    <Customer Details>
    <?for-each:G_2?>
    <Address>
    <?end for-each?>
    <?end for-each?>
    Its not getting inside the second loop.I have referred this link
    Re: Loop Question but it didn't help me much.Please let me know if am going wrong somewhere.
    Regards,
    Sudeep.

    Sudeep,
    The syntax of the for-each statements looks oke. but you have omitted some question marks after the < and before the >.
    Furhermore, there cannot be spaces in XML element names. So, "Customer Details" won't work. Change it to something like: "Customer_Details". Also be reminded that the element names are case-sensitive.
    try this:
    <?for-each:G_1?>
    <?Customer_Details?>
    <?for-each:G_2?>
    <?Address?>
    <?end for-each?>
    <?end for-each?>
    Regards,
    Kevin

  • For loop inside  a while loop, what order is that in big o??

    If say I have a for loop inside a while loop, then is that suppose to be in the order of O(n^2) right?? Is there any possibilities to change this into the order of O(n)??

    the other size and the temp size is abstact, which can be defined. This is actually for my union method, my teacher asks me to write this method using the order of O(n) which I think it is not possible. What do you guys think??
    Below is the code I have made:
    public Set<E> union(Set<E> other) {
              int count = 0;
              Iterator<E> iterator1 = other.iterator();
              while (iterator1.hasNext())
                   count++;
              Object[] temp = new Object [data.length+count];
              n = data.length+count;
              for (int i = 0; i<count; i++)
                   temp[i] = data;
              for (int j = count; j<temp.length; j++)
                   temp[j] = iterator1.next();
              data = temp;
              return null;
    but it still has same elements on it and I am thinking of a way on how to remove those same elements

  • While loop inside a timed loop

    Hi everybody!
       I'm using:
           - LV 7.1 + RealTime;
           - compactFieldpoint;
       I've noticed a strange behaviour, when I put a while loop inside a timed loop.  Let's fix timed loop with these settings:
           - 1 KHz clock
           - 1 ms period (yes, I know it's short....)
           - offset 0 ms
           - Phase 0
           - Discard missed period (ON) and MAintain original Phase (ON);
           - Timeout: -1.
       If inside this loo, I put a traditional while loop, waiting (say) for an event to occur, and if this event does not arrive, my cFP-2020 hangs! I mean, it becomes unreachable for the debugger, and, more, if I run a ping to it's address, after some cycles it becomes unreachable also from ping!
       Clearly, this code statement lock the fieldPoint, because if I remove the inner while loop all works.
      I know that with 1 ms period, timed loop always finishes late, but I set to discard missed period and timeout to -1. 
       It seems to me that sometimes Timed Loop add heavi overhead to programs, I'm turning to all while loop based tasks, even if my application has to be real-time!
       Advices welcomed! Have a nice day!
    graziano
    Solved!
    Go to Solution.

    I think the issue here is that putting your while loop inside a Timed Loop increases the priority for that task. Timed Loops can have dynamic priorities set over eachother, but they all run between Above Normal and Time Critical priority. My guess is that the debugger and built-in TCP functions run at Above Normal priority or less. This means your cFP isn't hanging, it's doing what it thinks is best. It's trying to finish this task before handling any lower-priority tasks.
    The suggestion to put a Wait function in your loop is an OK one. Keep in mind that you can actually set your wait time to zero instead of one and get the same positive benefit of handling other tasks. I would also suggest that you might look into waiting for this event in a lower priority (non-Timed) loop, and then transmit the appropriate data to your Timed Loop using an RT-FIFO or something. That might give you better handling. Just a thought....
    Jarrod S.
    National Instruments

  • Error -50103 occured with timed loop inside a while loop

    Hello everyone,
    i wrote an application to sample analog voltage from  DAQ6024E card (see the attachments).
    I have a big while loop in the VI because a I want to add some other functions later.
    In the "WHILE_Cont Acq&Graph Voltage-Int Clk.vi" I use a while loop inside the big while loop to read the samples. It's working properly.
    but when I use a timed loop inside the big while loop (see "TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi"), I get an error -50103 from the timed loop.  It seems that the first cycle is ok, but after the first cycle the error occurs.
    I don't know what happens with the timed loop, anyone can help me? what does the error -50103 mean? thanks a lot!
    PS: I am using LabVIEW 8.0
    Message Edited by molo511 on 10-22-2006 05:21 AM
    Message Edited by molo511 on 10-22-2006 05:23 AM
    Attachments:
    TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi ‏143 KB
    WHILE_Cont Acq&Graph Voltage-Int Clk.vi ‏75 KB

    hi molo511,
    I tested your program but only with simulated devices. I had to delete the wire to the timing, so that the timed while loop runs with 1kHz. Did you already try this? Because this works on my PC.
    I also found a link in our database that might be interesting for you.
    http://digital.ni.com/public.nsf/websearch/04BEDD9E9E91ED3486256D180048116D?OpenDocument
    Greets
    Philipp N.
    NI Application Engineer

  • Stopping a while loop inside a while loop

    Hello,
    I have a while loop which is inside a while loop which houses my enetire application, When stopping the inner while loop portions of my outer loop stop working, How do I setup the inner while stop that it will not interfeer with the outer while loop?
    Thanks,
    Gil,

    It sounds like he is using a simple archetecture.  But switching to a different archetecture may not be necessary.  Simply because it doesn't work, doesn't mean scrap the whole thing and start over.  He's got a bug and needs to fix it.  Is it the best archetecture to use, absolutely not, but simple or general archetectures can be effective based on the application.
    Post your VI so we can take a look and give you some pointers and suggestions for improvement.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Fast loop inside a slow loop?

    I have an application reading data once every hour, and writing this reading to disk continously - this works fine, however it looks like LV runs one complete iteration (an hour!) before asking me for the filename to save data in, even though that operation is step 8 of a structure inside the while loop, and the long-time-period timer is at step 9 or 10.
    How do I get the vi to run at normal speed, asking for the filename and writing the first set of data, and THEN going into the long time wait before looping around and executing again. PS - it runs fine, but there is one complete iteration before it comes up asking for the filename. When I run it for xx seconds time period its ok, but not for a long time period.
    Thx! (Newbie here..)

    The problem is that you have made the all too common mistake of using a multiframe sequence. This is why so many experience LabVIEW programmers have abandoned the use of multiframe sequences.
    See, a multiframe sequence is exactly like a single function, or a subVI for that matter. The data from the sequence isn't available until all frames of the sequence have executed. So, you send the data "out" of the sequence, but it "holds" at the output terminal until the sequence has completed, and then is sent "out".
    The other problem is that you have the Write to File... outside of this inner loop, so only after this loop is done (it only iterates once, so I don't even know why you have it there) will the loop exit, and data from that loop b
    e available.
    If I may suggest, try encapsulating each frame of the sequence into a subVI (or something along those lines, such as using multiple single frame sequences in a line). You will need to remove the inner loop, as it is uneccessary.
    It always helps to diagram your code ahead of time. I prefer pseudo code. This is an extremely useful method of aiding in writing your code as it puts things in perspective, in a serial fashion, so that you can visualize what happens, and when, and then just "plop down" each function as they appear in the pseudo code document.
    I hope this helps.

  • Ending a while loop inside a while loop

    How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way?
    Thanks.

    Hi Jasonalan,
    I am not sure what you are trying to implement, but it is true that the loops are not terminating because of data dependency. The stop button in the outer loop will not be read until the inner loop terminates.
    If you wish to terminate the two nested loops using a single stop button, you should read the stop button inside the inner loop and wire it to the conditional terminals in both the inner and outer loop. Again, there is no point in doing this unless you have some other logic along with the stop button to stop the loops. If only the stop button is being used to stop both the inner and outer loops, the outer loop will only execute once. In that case, you can just use a sequence structure followed by a single while loop.

  • Getting a for loop inside a while loop

    I've been having problems with the code below. I'm trying to get the 'while' loop to work so that the program will continue to run after a user types in a sentence. This is supposed to print out how many times a letter has been typed when a sentence has been put in, but it's not working right. It just keeps adding the first sentences numbers together even when a new sentence is typed out. I don't know what I'm doing wrong with this 'while' loop.
    import java.util.Scanner;
    import java.util.*;
    public class Count
    public static void main (String[] args)
    String phrase; // a string of characters
    int countBlank; // the number of blanks (spaces) in the phrase
    int length; // the length of the phrase
    int countA = 0; // the number of a's in the phrase
    int countT = 0; // the number of t's in the phrase
    int countE = 0;
    int countS = 0;
    char ch; // an individual character in the string
    Scanner scan = new Scanner(System.in);
    // Print a program header
    System.out.println ();
    System.out.println ("Character Counter");
    System.out.println ();
    // Read in a string and find its length
    System.out.println ("Enter a sentence or phrase ('quit' to quit): ");
    phrase = scan.nextLine();
    length = phrase.length();
    // Initialize counts
    countBlank = 0;
    // a while loop to allow user to keep entering phrases
       while (true)
       String line=scan.nextLine();
              System.out.println("Type quit to quit or enter a new phrase.");
         if(line.equals("quit"))
    break;
    // a for loop to go through the string character by character
    // and count the blank spaces
    for(int i = 0; i < phrase.length(); i++)
    ch = phrase.charAt(i);
    switch (ch)
    case ' ': countBlank++;
    break;
    case 'a':
    case 'A': countA++;
    break;
    case 't':
    case 'T': countT++;
    break;
    case 'e':
    case 'E': countE++;
    break;
    case 's':
    case 'S': countS++;
    break;
    // Print the results
    System.out.println ();
    System.out.println ("Number of blank spaces: " + countBlank);
    System.out.println ("Number of A's: " + countA);
    System.out.println ("Number of T's: " + countT);
    System.out.println ("Number of E's: " + countE);
    System.out.println ("Number of S's: " + countS);
    System.out.println ();
    }

    Ok well I don't really understand what you're saying, but here's an improved version of my code and I can get it to work, but I don't know how to turn the "do while" loop into just a "while" loop.
    import java.util.Scanner;
    public class Count3
         public static void main (String[] args) {
              String      phrase;           // a string of characters
              int      countBlank=0;      // the number of blanks (spaces) in the phrase
              int      length;           // the length of the phrase
              char      ch;                // an individual character in the string
              int      countA=0;       
              int      countE=0;
              int      countS=0;
              int      countT=0;
              String quit = new String("quit"); //String wasn't initialized
              Scanner scan = new Scanner(System.in);
              // Print a program header
              System.out.println ();
              System.out.println ("Character Counter");
              System.out.println ();
              do { //do-while loop
              // Read in a string and find its length
              System.out.println("Enter a sentence or phrase, or type \"quit\" to quit: ");
              phrase = scan.nextLine();
              length = phrase.length();
              // a for loop to go through the string character by character
              // and count the blank spaces, a's, e's, s', and t's
                   for (int i = 0; i <= length-1; i++) {
                        ch = phrase.charAt(i);
                        switch (ch) {
                             case ' ': countBlank++;
                             break;
                             case 'a':
                             case 'A': countA++;
                             break;
                             case 'e':
                             case 'E': countE++;
                             break;
                             case 's':
                             case 'S': countS++;
                             break;
                             case 't':
                             case 'T': countT++;
                             break;
                   // Print the results
                   System.out.println ();
                   System.out.println ("Number of blank spaces: " + countBlank);
                   System.out.println ("Number of a's: " + countA);
                   System.out.println ("Number of e's: " + countE);
                   System.out.println ("Number of s's: " + countS);
                   System.out.println ("Number of t's: " + countT);
                   System.out.println ();
                   countA=0; countE=0; countS=0; countT=0; countBlank=0;
              }while (!(phrase.equalsIgnoreCase(quit)));          
         }//end main
    }//end class Count

  • Can we place Analog in Read(AI-RE​AD) Vi inside the while loop for high sample rate like 22ks/s?

    I am using E-series Card for data acquisition.My requirement is to sample the channel, and check the 10 samples for certain condition.both at a time.What should be done can we place the AI-READ vi inside for or while loop for this purpose?

    Hello,
    Yes, you can include the AI Read.vi inside the while loop, you would just need to specify the number of scans to read for every iteration of the loop. Then, after AI Read.vi has read the data, you can do what ever kind of manipulation of the data you would like, before the next iteration of the loop. The one thing to watch out for is what ever manipulation of the data you do, be sure that it doesn't take to long whereas the buffer holding the data starts to back up. That can be checked by looking at the scan backlog output of the AI Read.vi, which will tell you how many scans have been acquired but haven't been read into your program.
    Hope this helps!
    Regards,
    Steven B.
    Applications Engineering, NI

  • How do I break a for loop (inside) and a while loop (outside) at the same time by a control button

    I have a while loop (outside) and a for loop (inside) and a control button within the for loop.  I want to stop the program by click the botton without finishing the for loop.  How can I do that?
    Thank you in advance.

    HI Please find attached snapshot Regards, Santosh
    Message Edited by SanRac on 12-17-2009 05:12 AM
    Message Edited by SanRac on 12-17-2009 05:13 AM
    Attachments:
    Snap1.png ‏4 KB

  • How to speed up my code inside the for loops,

    how to speed up my code inside the for loops using c# WinForm.

    Hi  John,
    Please take a look at the reply from Wyck in the following thread.
    How to speed up for loop?
    His answer is very comprehensive.   Thanks.
    Best regards,
    kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Simple example - Break FOR loop inside an event structure based on Front panel event change.

    I am running a for loop inside a state machine architecture that contains a FOR loop. How can I break this For loop based on Event change in front panel ??
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.vi ‏19 KB
    Case inside Event.ctl ‏6 KB
    Case inside Event 2.ctl ‏6 KB

    Okay. Accpeting that the design is not favorable and not advantageous when my program expands. I have begin to follow producer/consumer programming architecture.
    Please find the attached program which is a simple producer consumer with event structure. I wonder how could I stop looping around the producer and consumer loops over and over again. I am pretty sure that this ENQUEUE ELEMENT loops back to the consumer loop and starts from begining.
    I hope my first program in PC architecture with State machine and Event structure is correct. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.3-ProducerConsumer Event.vi ‏25 KB
    Case inside Event.ctl ‏6 KB

  • How to use String Tokeniser inside this for loop?

    [i][i]hi there..
    i am reading all the file inside a directory and get the latest modified file than i have to tokenise it and juz read the number. For example my file name that is last modified will be abc_123.txt but i just want it to appear 123.
    i manage to do it separately how can i put the tokeniser inside my for loop?
    my directory
    for (int i = 0; i < files.length; i++)
                        if(files[i].isFile())
                             if(lastModifiedFile == null){
                             lastModifiedFile = files[i];
                             String mylastModifiedFile = lastModifiedFile.toString();
                             StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
                             String modified = tokens.nextToken().substring(modified.length-4);*/
                             if(lastModifiedFile != null)
                                  if(lastModifiedFile.lastModified() < files[i].lastModified())
                                       lastModifiedFile = files[i];
    my tokeniser is this
    String mylastModifiedFile = lastModifiedFile.toString();
                             StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
                             String modified = tokens.nextToken().substring(modified.length-4);*/
                   }

    [i][i][i]hi there..
    i am reading all the file inside a directory and get ...
    tokens.nextToken().substring(modified.length-4);*/
                   }[/i][i][/i][/i][/i]Is there some reason for this baroque formatting? Please use the
    code tags as explained in one of your other threads on this topic:
    http://forum.java.sun.com/thread.jspa?threadID=793441&messageID=4510858#4510858

Maybe you are looking for

  • Quick change of language for spell check

    Hi everyone, I am a translator and use three languages on my MacBook Air and swap from one to another 100+ times a day. It's a bit annoying to change the spell check using right click, going to the grammar section, searching for the language... Is th

  • How to set default file type for screen capture?

    I want to change the default from .jpg2 to .jpg when doing a screen selection capture (cmd-shft-4). Where is the place to do this? Thank you, todd

  • Will not load after update

    I have an Imac DV with OS X 10.3. I turned it on the other day and after it loaded up, it said there were updates available. I had it install the updates and then when it tried to restart, it went through loading up until it got into the loading wind

  • IWeb blog entry with an earlier date than today?

    Is there a way to create an entry in iWeb that has a date before today's date? Say I want to create an entry of something that happened five days ago... When I create an entry, it automatically sets the date to today. Is there any way to change the d

  • Unable to specify web application Login Module

    HI all, i have the following problem with JDev11Tech Preview R2: I have jazn login module which i specify under the Tools -> Embedded OC4J preferences -> Authentication -> Login Configuration The login module data is filled into the system-jazn-data.