Trouble running for loop

     public void enterBackMultiple(int number)
          System.out.println("Number of times to run loop is: " + number);
          for(int i = 0; i < number; i++);
               line.enqueue(new Customer());
               System.out.println("Adding a customer.");
          System.out.println("Done running enterBackMultiple Method.");
     }When I pass in 5, the loop is suppose to run 5 times. Instead I get this:
Number of times to run loop is: 5
Adding a customer.
Done running enterBackMultiple Method.
Which shows that the for loop only ran once. It should've printed "Adding a customer" 5 times. Whats going on??
EDIT: nvm i see whats wrong. stupid mistake. Thanks.
Edited by: backtoreality15 on May 19, 2008 5:40 PM

Here is your for loop again. See if you can spot the mistake now.
for(int i = 0; i < number; i++); {
    line.enqueue(new Customer());
    System.out.println("Adding a customer.");
}Edited by: flounder on May 20, 2008 10:54 AM
Ah, so you already spotted the mistake.

Similar Messages

  • Run for loop inside event node

    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    Thanks & Regards,
    Harish. G.

    harishg92 wrote:
    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    You're implementing a For loop inside an event structure? (I don't know of any event "node" in which you can run a For loop)
    If so, that's a bad idea because LabVIEW won't be able to process any events while waiting for your For loop to get done, which might be why its crashing.
    There are tricks to accomplishing what you're trying to do without putting any for loops inside event structure. See what I have  attached and if it helps. "N" is number of times you run your For loop, timeout is whatever delay you want in each loop. This can be done in many ways without adding delays in events, another way could be to fire a separate subVI using Asynchronous call (without waiting for the VI to finish) during those delays, just make sure that such subVI finishes processing within your allocated time (that's how I'd ideally implement things). That method is better because you're doing minimal work inside events structure while using wait period wisely in a separate/parallel process.
    I hope that I understood you correctly and did not go off on a tangent.
    -BTC
    New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI
    Attachments:
    ForLoop inside Event Structure.vi ‏11 KB

  • Variable not defined after running for() loop.

    Hi,
    I have a little problem, I have created a for loop, which seems to work, except that a variable within the for() loop gets lost, because if I try to call the variable after the loop, it says it's not there. anyway, here is my code, followed by the error. Thanks!
    <%
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:testdb");
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String sql_count = "SELECT COUNT(*) FROM users";
    ResultSet cn = stmt.executeQuery(sql_count);
    cn.first();
    int row_count = cn.getInt(1);
    int num = (int)(Math.random() * (row_count));
    int inum;
    for (inum=0; inum<row_count; inum++)
    int jnum = inum + num;
    if (jnum >= row_count) { jnum = 1; }
    String sql = "SELECT * FROM users WHERE ID = "+jnum+"";
    ResultSet rs = stmt.executeQuery(sql);
    int ce = rs.getInt("cr_earned");
    int cu = rs.getInt("cr_used");
    if ((ce-cu) > 0) { inum = row_count + 1; }
    String sql = "SELECT * FROM users WHERE ID = "+jnum+"";
    ResultSet rs = stmt.executeQuery(sql);
    rs.first();
    String url = rs.getString("url");
    con.close();
    %>
    ***********************ERROR***********************
    Generated servlet error:
    C:\tomcat\jakarta-tomcat-4.0\work\localhost\examples\gtt\surf$jsp.java:93: Undefined variable or class name: rs
    rs.first();
    ^
    An error occurred between lines: 17 and 43 in the jsp file: /gtt/surf.jsp
    Generated servlet error:
    C:\tomcat\jakarta-tomcat-4.0\work\localhost\examples\gtt\surf$jsp.java:94: Undefined variable or class name: rs
    String url = rs.getString("url");
    ^

    now i've defined them all before the loop and I get this error. Error is following modified code below.
    <%
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:testdb");
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String sql_count = "SELECT COUNT(*) FROM users";
    ResultSet cn = stmt.executeQuery(sql_count);
    cn.first();
    int row_count = cn.getInt(1);
    int num = (int)(Math.random() * (row_count));
    int inum;
    int jnum;
    ResultSet rs;
    for (inum=0; inum<row_count; inum++)
    jnum = inum + num;
    if (jnum >= row_count) { jnum = 1; }
    String sql = "SELECT * FROM users WHERE ID = "+jnum+"";
    rs = stmt.executeQuery(sql);
    int ce = rs.getInt("cr_earned");
    int cu = rs.getInt("cr_used");
    if ((ce-cu) > 0) { inum = row_count + 1; }
    rs.first();
    String url = rs.getString("url");
    con.close();
    %>
    ***********ERROR***************
    An error occurred between lines: 17 and 45 in the jsp file: /gtt/surf.jsp
    Generated servlet error:
    C:\tomcat\jakarta-tomcat-4.0\work\localhost\examples\gtt\surf$jsp.java:95: Variable rs may not have been initialized.
    rs.first();
    ^
    Thanks anyone.... ;-)

  • Trouble with "for loop"

    Hi all,
    how can I fix this problem
    Rookie; LV 2011 on WIN 7
    Solved!
    Go to Solution.

    Jkhourigan wrote:
    Disable indexing on the right hand side of the for loop.
    Consider using shift registers instead.
    That will indeed clear the error message but then your For loop will want to know how many times to iterate and I suspect you will only want to iterate once so why use the For loop?
    Toss it.
    If you were using the For loop to ensure a delay ... after (?) the transmit ...
    THere is no guarentee the wait will happen after since the is no data flow dependencies. If wan to delay after, add another frame between Xmit and rcv. Please note that I am talking about the most basic data flow ideas that drive LabVIEW and in serious coding data flow alone should drive the program execution and seq frames are used sparingly.
    Quesion anything I said above. Since the paradigm shift for LV may be weird.
    You at least have gotten past the "how do I wire things up?" challenge that frustrated me when I got started.
    Have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • More trouble with for loops

    This was my attempt:
    function poor(){if(money < shopwin["prc"+$].text){shopwin["itm"+$].textColor = 0x999999;
    shopwin["prc"+$].textColor = 0x999999;}
    if(money >= shopwin["prc"+$].text){shopwin["itm"+$].textColor = 0xFFFFFF;
    shopwin["prc"+$].textColor = 0xFFFFFF;}
    for ($=1;$<9;$++){poor();}  
    at compressing this:
    function poor(){
    if(money < shopwin.prc1.text){shopwin.itm1.textColor = 0x999999;
    shopwin.prc1.textColor = 0x999999;}
    if(money < shopwin.prc2.text){shopwin.itm2.textColor = 0x999999;
    shopwin.prc2.textColor = 0x999999;}
    if(money < shopwin.prc3.text){shopwin.itm3.textColor = 0x999999;
    shopwin.prc3.textColor = 0x999999;}
    if(money < shopwin.prc4.text){shopwin.itm4.textColor = 0x999999;
    shopwin.prc4.textColor = 0x999999;}
    if(money < shopwin.prc5.text){shopwin.itm5.textColor = 0x999999;
    shopwin.prc5.textColor = 0x999999;}
    if(money < shopwin.prc6.text){shopwin.itm6.textColor = 0x999999;
    shopwin.prc6.textColor = 0x999999;}
    if(money < shopwin.prc7.text){shopwin.itm7.textColor = 0x999999;
    shopwin.prc7.textColor = 0x999999;}
    if(money < shopwin.prc8.text){shopwin.itm8.textColor = 0x999999;
    shopwin.prc8.textColor = 0x999999;}
    if(money >= shopwin.prc1.text){shopwin.itm1.textColor = 0xFFFFFF;
    shopwin.prc1.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc2.text){shopwin.itm2.textColor = 0xFFFFFF;
    shopwin.prc2.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc3.text){shopwin.itm3.textColor = 0xFFFFFF;
    shopwin.prc3.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc4.text){shopwin.itm4.textColor = 0xFFFFFF;
    shopwin.prc4.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc5.text){shopwin.itm5.textColor = 0xFFFFFF;
    shopwin.prc5.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc6.text){shopwin.itm6.textColor = 0xFFFFFF;
    shopwin.prc6.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc7.text){shopwin.itm7.textColor = 0xFFFFFF;
    shopwin.prc7.textColor = 0xFFFFFF;}
    if(money >= shopwin.prc8.text){shopwin.itm8.textColor = 0xFFFFFF;
    shopwin.prc8.textColor = 0xFFFFFF;}
    poor();
    I tried a similar code to the first (above) for the following list, but it also failed.
    shopwin.itm1.text = m_shop.inv.itm1.nm; shopwin.prc1.text = m_shop.inv.itm1.prc;
        shopwin.itm2.text = m_shop.inv.itm2.nm; shopwin.prc2.text = m_shop.inv.itm2.prc;
        shopwin.itm3.text = m_shop.inv.itm3.nm; shopwin.prc3.text = m_shop.inv.itm3.prc;
    //(I actually needed 5 more just like this for itm4 through itm8)
    I based the top code on this:
    function buy(){if(actionBox == m_shop.inv["itm"+n].nm && money >= m_shop.inv["itm"+n].prc){
        char.inv["itm"+n] = m_shop.inv["itm"+n]; money = money - m_shop.inv["itm"+n].prc;} ;}
    for (n=1;n<9;n++){buy();}
    which worked fine. I should mention this last code is nested inside an "onRelease" as are the others.

    I will second the Flash suggestion. Great a .flv file and play it on your site with a flv player. Some are more difficult than others to use.
    NOTHING is fool proof with this kind of stuff. Flash has the highest install rate on all computers and is as close as you can get to fool proof. You can also put a link on you site to download the latest flash player. The other plus is that it tends to have the best results with low file sizes. This is what YouTube and similar sites use to play their video.
    PS. I highly suggest this flv player... It's free for non-commercial use and almost free for other uses...
    http://www.jeroenwijering.com/?item=JWFLVPlayer

  • Troubles with for-loop

    Hi I'm new her...
    Could anybody explain to me why my code is not doing what i want it to do.
    I want to get
    xxx
    xx
    x
    and not
    X
    X
    X
    X
    X
    X
    I'm doing a German course, but can't find it anywhere. Starting to get desparte after 3 hours searching!
    public class Aufgabe5 {
    public static void main (String[] args) throws Exception {
      for(int zeile = 1; zeile <=3; zeile++) {
       for(int spalte = 1; spalte <= zeile; spalte ++) {
        System.out.println("+");
       System.out.println(" ");
    }Edited by: javastartert on Nov 4, 2008 11:45 AM
    Edited by: javastartert on Nov 4, 2008 11:45 AM
    Edited by: javastartert on Nov 4, 2008 11:45 AM
    Edited by: javastartert on Nov 4, 2008 11:47 AM

    thanks for the help!i think it's an important clue....
    now i got a new thing, and a new question
    now i want to make a sandglass with java ( 5 stars, 3 stars, 1 star, 3 stars, 5 stars)
    xxxxx
    xxx
    x
    xxx
    xxxxx
    and than in the nice sandglass form offcourse.. (can't get it that way over here in this topic)
    but it doesn't seem to work.. where did i go wrong?
    public class Aufgabe5 {
         public static void main(String[] args) {
              final int memory = 5;
              final char sign = '+';
              int count = 0;
              int selection = 1;
              switch (selection) {
              case 1: {
                   for (int size = memory; size > 0; size -= 2, count++) {
                        if (count != 0) {
                             System.out.println();
                        for (int line = count; line > 0; line--) {
                             System.out.print(' ');
                        for (int digits = size; digits > 0; digits--) {
                             System.out.print(sign);
                   break;
              case 2: {
                   int size = memory;
                   while (size > 0) {
                        if (count != 0) {
                             System.out.println();
                        int line = count;
                        while (line > 0) {
                             line--;
                             System.out.print(' ');
                        int digits = size;
                        while (digits > 0) {
                             digits--;
                             System.out.print(sign);
                        count++;
                        size -= 2;
                   break;
    }

  • Is there a way to run a For Loop independen​tly within a While Loop in LabVIEW 2013?

    In my program I would like to run a For loop inside of a While loop, and have them run independently, at their own execution rates.  As a test, I wrote a simple VI with a While loop with 1 second timing, and into this I inserted a For loop with 3 second timing.  I created indicators for both iteration terminals.  Upon running the VI, I found the While loop waits for the For loop to run N times before the While loop executes again.  I also found that sometimes the first iteration of the For loop will end at 1 second rather than 3 seconds, and the STOP button to terminate execution of the While loop does not always work.
    Solved!
    Go to Solution.

    ksinks wrote:
    Thanks, how would you synchronize the loops?  I have gone through the Getting Started exercises and manual.
    Why would synchronization matter? Did you want them to run independantly at their own speed or not?
    Regardless, there's a synchronization pallette with functions for this, as Occurance.
    Other solutions include a common loop counter and a case structure executing every X'th iteration, or having the faster loop send a queue or event every X'th loop that controls the slower loop.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Having trouble with inner for loop values in my procedure

    Hi ...
    I am using oracle 10g and here is my procedure ...
    create or replace procedure sales_information is
    v_qty number(10);
    rem_qty number(10):=0;
    cursor pck_quantity is
    select * from sales_info;
    cursor no_of_labels is
    select ceil(sum(nvl(total_quantity,actual_quantity))/400) from sales_info;
    begin
    for j in no_of_labels
    loop
    for i in pck_quantity
    loop
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    if v_qty>=i.packed_quantity and rem_qty=0 then
    insert into sales_order values------------
    rem-qty:=v_qty-i.packed_quantity;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>=400 then
    insert into sales_order values-----------
    rem_qty:=v_qty-rem_qty;
    v_qty:=rem_qty;
    exit;
    else if v_qty>=i.packed_quantity and rem_qty>0 then
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    insert into sales_order values-----------
    else if v_qty is null and rem_qty>0 and then
    insert into sales_order values-----------
    else if v_qty<i.packed_quantity and rem_qty:=0 then
    rem_qty:=v_qty;
    else if v_qty<i.packed_quantity and rem_qty>0 then
    if (v_qty+rem_qty)>400 then
    insert into sales_order values-----------
    rem_qty:=v_qty+rem_qty-i.packed_quantity;
    v_qty:=rem_qty;
    end if;
    end if;
    end loop;
    end loop;
    The inner for loop will retrieve the same values of v_qty for every iteration of outer for loop when it runs the following select statement:
    select nvl(i.total_quantity,i.actual_quantity) into v_qty from sales_info;
    and thus loses the previously computed values of v_qty and rem_qty
    in the previous iteration of outer for loop whereas i want the inner for loop to iterate over it's previously computed values of v_qty and rem_qty but cant think of a workaround.

    h4. Thanks Dave for explanation. Hope I understood your requirement and below code resolves that
    -- Creating table SALES_INFO
    CREATE TABLE SALES_INFO
    (    S_NO             NUMBER(1),
         ACTUAL_QUANTITY  NUMBER(10),
         TOTAL_QUANTITY   NUMBER(10),
          PACKED_QUANTITY  NUMBER(10)
    -- Creating table sales_order
    CREATE TABLE SALES_ORDER
    (    S_NO             NUMBER(1),
         LABEL            VARCHAR2(30),
         ORDER_QUANTITY   NUMBER(10)
    -- Push SALES_INFO data
    INSERT INTO SALES_INFO VALUES(1,1000,800,400);
    INSERT INTO SALES_INFO VALUES(2,800,600,400);
    INSERT INTO SALES_INFO VALUES(3,800,NULL,400);
    INSERT INTO SALES_INFO VALUES(4,NULL,600,400);
    CREATE OR REPLACE PROCEDURE populate_sales_order AS
    CURSOR get_sales_info IS
    SELECT s_no,
               NVL(total_quantity,actual_quantity) total_quantity,
            packed_quantity
    FROM   sales_info;
    v_s_no          PLS_INTEGER := 0;
    v_rem_qty     PLS_INTEGER := 0;
    v_label_num   PLS_INTEGER := 1;
    BEGIN
    FOR rec IN get_sales_info LOOP
        v_rem_qty := rec.total_quantity + v_rem_qty;
        v_s_no    := rec.s_no;
         WHILE v_rem_qty >= rec.packed_quantity LOOP
           INSERT INTO sales_order( s_no, label, order_quantity)
           VALUES ( v_s_no, 'LABEL' || v_label_num, rec.packed_quantity );
           -- Reduce the packed qty from total qty and increment label counter
           v_rem_qty   := v_rem_qty - rec.packed_quantity ;
           v_label_num := v_label_num + 1;
         END LOOP;
    END LOOP;
    -- Put the last lot remaining qty into last carton
    IF v_rem_qty > 0 THEN
    INSERT INTO sales_order( s_no, label, order_quantity)
    VALUES (v_s_no, 'LABEL' || v_label_num, v_rem_qty );
    END IF;
    COMMIT;
    END;
    S_NO    LABEL                                ORDER_QUANTITY
      1          LABEL1                                    400
      1          LABEL2                                    400
      2          LABEL3                                    400
      3          LABEL4                                    400
      3          LABEL5                                    400
      4          LABEL6                                    400
      4          LABEL7                                    400
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Force Multiple For Loops to run Sequentially

    I have the following sequence of 3 for loops, and I need the last for loop to execute after the other two have properly incremented the *in pointer, and that they are through executing before the data begins processing in the third loop. The purpose of the 1st 2 loops is just to skip over header data.
    #include <math.h>
    #include <stdint.h>
    #include "xilly_debug.h"
    #define SKIPBYTES 896
    #define SKIPCOUNT 448 // (896/2)
    // When creating data cube, it is helpful to discard unneeded bands.
    #define SHORTEST_BAND_TO_INCLUDE 171 // Must be between 1 and 519
    #define SHORTEST_SKIPCOUNT 119016 // (171*696*2/2)
    #define LONGEST_BAND_TO_INCLUDE 453 // Must be between 2 and 520, greater than SHORTEST_BAND_TO_INCLUDE
    #define LONGEST_SKIPCOUNT 46632 // (67*696*2/2)
    #define PROCESSCOUNT 196968 // (283*696*2/2)
    // BANDS = LONGEST_BAND_TO_INCLUDE - SHORTEST_BAND_TO_INCLUDE + 1;
    #define BANDS 283
    #define RADIANCE_SCALING_FACTOR 100
    uint16_t radCorr(uint16_t unCorrPixel, int coeffIndex){
    uint16_t corrPixel; //Holder for the corrected pixel value
    float a2, b2, c2; //Intermediate variables for the actual calculations
    if (coeffIndex > 282)
    coeffIndex = 0;
    c2 = cf[coeffIndex];
    a2 = (float) unCorrPixel;// * cf_mn;//L0R
    b2 = a2*c2*RADIANCE_SCALING_FACTOR;
    corrPixel = *((uint16_t *) &b2); // Convert float to uint16_t
    return corrPixel;
    void xillybus_wrapper(int *in, int *out) {
    #pragma AP interface ap_fifo port=in
    #pragma AP interface ap_fifo port=out
    #pragma AP interface ap_ctrl_none port=return
    uint32_t a1; //Holds input data
    uint16_t x1; //Holds input after converting to float; input to function
    uint16_t y1; //HOlds output of function, to return to processor
    static int n = 0; //Index for correlation matrix
    static int i = 0;
    // Handle input data
    //Skip over SKIPBYTES
    for(i = 0; i < SKIPCOUNT; i++){
    *in++;
    if(i<20){
    xilly_puts("Skipcount Index Value:\n");
    xilly_decprint(n, 5);
    xilly_puts("\n");
    xilly_puts("Value of *in pointer:\n");
    xilly_decprint(*in, 5);
    xilly_puts("\n");
    //Discard Lower Bands
    for(i = 0; i < SHORTEST_BAND_TO_INCLUDE; i++){
    *in++;
    if(i<20){
    xilly_puts("Shortest Band to Include Index Value:\n");
    xilly_decprint(n, 5);
    xilly_puts("\n");
    xilly_puts("Value of *in pointer:\n");
    xilly_decprint(*in, 5);
    xilly_puts("\n");
    n++;
    for (i = 0; i < PROCESSCOUNT; i++) {
    a1 = *in++;
    x1 = *((uint16_t *) &a1); // Convert uint32_t to uint16_t
    if(i<20){
    xilly_puts("Processing Loop Iteration (i) Value\n");
    xilly_hexprint(i, 5);
    xilly_puts("\n");
    xilly_puts("Input Value To radCorr Function:\n");
    xilly_hexprint(x1, 5);
    xilly_puts("\n");
    xilly_puts("Index Value Before Function:\n");
    xilly_decprint(n, 5);
    xilly_puts("\n");
    xilly_puts("Value of *in pointer:\n");
    xilly_decprint(*in, 5);
    xilly_puts("\n");
    // xilly_puts("Coefficient Value Function:\n");
    // xilly_decprint(cf[n], 5);
    // xilly_puts("\n");
    // Run the calculations
    y1 = radCorr(x1, n++);
    if(i<20){
    xilly_puts("Index Value after Function:\n");
    xilly_decprint(n, 5);
    xilly_puts("\n");
    // Handle output data
    xilly_puts("Returned Value from Function:\n");
    xilly_hexprint(y1, 5);
    xilly_puts("\n");
    xilly_puts("\n");
    *out++ = y1;

    all loops are accessing a shared resource (*in++) with read consequences. It would be difficult to imagine HLS would schedule these in parallel. If you want to make sure, I guess you can add a ap_wait() between the loops but I am pretty sure this is not necessary.

  • How to make a button to stop and run a for loop?

    How to make a button to stop and run a for loop?  and if it is stopped it shall start from where i t stopped.

    Your VI has some very fundamental flaws.
    The start/stop button is outside the FOR loop, thus it will NOT get read during execution of the FOR loop, but only before the FOR loop starts. Think dataflow!
    Thus the terminal of the start/stop button belongs inside the FOR loop.
    Your FOR loop iterates 20x, which probably takes about a nanosecond. You will NOT be fast enough to reliably press the start/stop button during a specific iteration of the FOR loop.
    Your code does not "stop and run" a FOR loop (sic). The loop always spins, but executes an empty case when "Stopped". I guess that's what you actually want?
    Once you solve (2), the x indicator will contain a random value whenever you "stop".
    As soon as the 20 iterations complete, the outer while loop spin an things start over, another nanosecond later.
    Place e.g. a 500ms wait inside the FOR loop to solve this.
    Don't place terminals of indicators on top of formula nodes.
    Your formula does not produce any output, so really has no purpose.
    Use a real "stop" button to terminate the while loop (mechanical action: latch when released). Right now you are using a plain switch, which does not reset to false before the next run. This means that you need to manually reset it before running the program again.
    It is oftern useful to operate the VI in execution highlighting mode. You will immediately see that your button does not get read during execution of the FOR loop. Try it!
    LabVIEW Champion . Do more with less code and in less time .

  • How to run a loop for 1hour

    Hello All,
                 I am very new to labview and its components. I want to program a loop which would run for one hour.
    Actually, I would like to make it more user friendly, by asking the operator to enter how long he would like to run the code.
    Can anyone please suggest me how to do this?
    Please excuse me if I entered into wrong forum ...
    Now on LabVIEW 10.0 on Win7
    Solved!
    Go to Solution.

    Something like this
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Example.vi ‏8 KB

  • How to make a loop run for specific period of time ?

    hello !
    i'm new to labview and could'nt found how to make a loop run for 2 sec for example, and then to exit.
    Solved!
    Go to Solution.

    Hi Hookso,
    You can do it using the different loops like While loop and For Loop. Roderic has already stated how to do it using a for loop. I have illustrated in the attached vi how to do it using a while loop and Elapsed Time function. Take a look.
    Regards,
    Nitzz
    (Give kudos to good Answers and Mark it as a Solution if your problem is Solved) 
    Attachments:
    Untitled 2.vi ‏36 KB

  • What is the best way to pass a controllin​g signal out of a sub vi or more than one layer of for loop, while the sub vi or for loops are still running?

    I have a vi that runs through two for loops and a while loop, then after a certain number of iterations on the inner while loop it is supposed to pass a trigger to a case stucture to start measurement. I have tried using a local variable attached to a boolean control which in turn is attached to the true case of the case structure involving the measurement sub vi. What is happening is that the boolean control will light on the front panel at the correct # of iterations in the while loop, as if true, but the measurement is not taken, and the boolean control never goes back to false. It remains lit. Am I u
    sing the local variable incorrectly? If so, where am I going wrong.
    Attachments:
    GL_Flicker.vi ‏118 KB
    Take_Measurements.vi ‏147 KB

    Hello planar,
    There are multiple ways to pass control information between loops and VIs and each one has its place. For simple VIs like your example, a local variable will be fine.
    The main reason the subVI is not running is that the case structure is not continuously polling the Boolean control. This is because the case structure is not inside a loop and as such will only read the Boolean value once and execute once. Encasing the case structure and control inside the while loop should solve the issue of the subVI not running.
    You may find the following links of help in creating more robust and advanced VI architectures.
    Application Design Patter
    ns: Master/Slave
    LabVIEW Application Design Patterns
    Keep up to date on the latest PXI news at twitter.com/pxi

  • No IP address, everytime I'm close to my mums mac running off the same wifi, it's giving me this error. I can trouble shoot for about 3 mins and fix it, but it just keeps happening and I need a permanent fix for it. Any help?

    No IP address, everytime I'm close to my mums mac running off the same wifi, it's giving me this error. I can trouble shoot for about 3 mins and fix it, but it just keeps happening and I need a permanent fix for it. Any help?

    this is what you need to do to exclude everything apart from desktop.
    on time machine preferences, click on Options
    click plus sign, on the new window, click macintosh HD
    do a Control + A then deselect users then click okay
    go to options again, plus sign, go to users, control +A then deselect your user account
    go to options again, plus sign, go to your user account, control + A, deselect desktop
    start the back up.

  • Customize for loop to run from x value to y value

    How can you customize a for loop to run from a specified i-value.
    Basically how can I do this c code in Labview:
    for(i=2; i<10; i++)

    Guy04,
    you cannot influence the iterator of any loops in LabVIEW. So there is (sadly) no way to initialize the iterator to a value != 0.
    Nevertheless, you can "emulate" this by doing what i did in the screenshot. Just remember that "N" has to be the difference between end- and startvalue of your iterator (in your example 10 - 2 = 8 ).
    hope this helps,
    Norbert B.
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    ForLoop.jpg ‏7 KB

Maybe you are looking for