Indexing in alternate runs of a loop

I would like to send data out of a for loop only in alternate runs like i=1,3,5,7,9....etc...But i want to use the indexing feature to send the data out of the loop..so any idea how this can be done..or do i need to store in an array and then send the whole array oout of the loop at the end of the loop?

Not sure I completely understand. Is this data supposed to be used while the loop is running? If so, you need to use some other mechanism for getting the data out of the loop. The mechanism depends on who is the consumer of the data. You have lots of options: local variables, global variables, shared variables, queues, notifiers, etc. One should not be automatically discounted simply because somebody has a personal dislike of them. Although I'm sure at this point you'll get the usual flurry of local variable haters and global variable haters. Cue the bandwagons!
If the data is to be used after the loop completes, then you can simply use a shift register to populate the final array. The best way to do this is to pre-allocate the array ahead of time and use Replace Array Subset inside the loop within a case structure that's driven by the loop iteration being even or odd. 

Similar Messages

  • 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

  • Is there a way to have presentation run automatically on iPad and run in a loop?

    I have built a presentation that I would loke to run in a loop without continually touching the screen. Is that possible?

    Better to ask in the community dedicated to iWork for iOS. Those of us here don't all have an iPad.

  • How a variable in C++ gets updated from calling a labview dll running in a loop?

    Hi,
    I have created a dll which is called from a C++ program. The dll has been created from a vi which continuously runs in a loop (this is necessary because I need to control some hardware in real-time). When I call the function from C++ I can see the front panel of the vi working properly, i.e. all variables are updated in real time on the labview panel (which I will set as not visible once i get this problem sorted out).
    However, I can't get the variables' values getting updated in my C++ program and I need these values to change in which way the hardware should behave ... is there any example somewhere in which something similar has been done? I have seen some examples where a dll is called from C++ with a vi function but not running in a loop. In these examples, the vi function passes the datum to the C++ software once is finished ...  
    thanks very much for your help,
    kind regards
    Sergio

    Hi smercurio_fc!
    Thanks very much for your answer!
    I have already an inter-process communication, where there are two threads running in parallel. In one thread the C++ code is running while in the other the LabVIEW code is running. The labview function is passing the "output" variables as pointers too.
    _1DScan(ReqForce,&StopAlign,0,&ReadForce,&Piezo_running,&RS232OK,&Running);
    the function is called using the following:
    void CFMControl::FMThreadProc()
        _1DScan(ReqForce,&StopAlign,0,&ReadForce,&Piezo_running,&RS232OK,&Running);
        return;
    When I run the C++ code I can see both threads working by seeing data being updated in C++ front panel (data that belongs to C++) and in labview fron panel (data that belongs to labview). However, when I try to use any of the outputs coming from labview I can't get them updated....

  • .VOB Editing S/w to add jpeg images to the .vob video file and run in a loop

    hi,
    I have 2 .vob files with me which i need to run in a loop seperately on the plazma screens. In addition to it, in one of the video (.vob) files I have to add some jpeg pictures at the end and make the video looping. I have tried a lot but could not find any relevant software to do so Any ideas??? I am kind of new to this video editing thing... i tried to convert it into avi or mpeg formats but in that case when i call it in other program like flash the dimension and resolution on full screen mode gets distorted.
    Please let me know how can I edit this .vob file and integrate images to it and make it rum in a loop.
    Regards,
    Vandee

    Frequently answered question
    Cheers
    Eddie
    Forum FAQ
    Premiere Pro Wiki
    - Over 250 frequently answered questions
    - Over 100 free tutorials
    - Maintained by editors like
    you

  • 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 .

  • When PC System timing hits 0000hrs Loops back to start and runs again using Loop function?

    When PC System timing hits 0000hrs Loops back to start and runs again using Loop function?

    It's all described in the help for it. Vista version:
    Attachments:
    Task Scheduler.png ‏61 KB

  • Why are date and time strings lost when indexing an array in a for loop

    Hi, 
    I have an application where i'm reformatting data from a spreadsheet for graphical display on a LabVIEW dashboard.
    the original spreadsheet has date and time values in separate columns, and i'm merging them and converting to a timestamp value.  But something's not working.  Does anyone know why the string value is lost when the array indexes into this for loop?
    Attachments:
    failed array index.png ‏142 KB

    Can you attach your VI with some typical values? (e.g. create in indicator on the 2D array, run your VI, then turn the indicator (now containing data) into a diagram constant). Place the FOR loop related code and that diagram constant into a new VI and attach it here.
    How many times does the FOR loop run? Could it be that the last element of each 1D array is an empty string? (unless you put a wait inside the FOR loop, you'll never see the other elements in the probe)
    LabVIEW Champion . Do more with less code and in less time .

  • How to index DancePack clips (or my own loops) into STPro?

    How do I get STPro to index Dancepack clips (and my own clips) so that they show up in a search for clips?
    I put them in the clips in HD/Library/Audio/Apple Loops/Apple folder, along with the "Jam Pack World Music" which is indexed by STPro.

    In case you haven't already, you need to add the (sub)folder - via the Setup button, in the Search pane of the Browser window - to the list of indexed locations.
    Or are you asking this question because that isn't working for you?

  • Calling vi front panel object update in a running sub-vi loop?

    Hello All. I have a calling sub-vi with a "Start Test" button on the front panel. I passed a control reference for that Start button into a sub-vi that runs in a while loop. The while loop is monitoring that Start button and other things.
    Problem: Once the sub-vi runs, it no longer takes updates from that Start button. My program never leaves that while loop in response to my Start button.
    Is there some way I can make the sub-vi take an updated value from the calling vi?
    Attached is the sub-vi (top level, LabVIEW 2011). Please note that I have already tried putting the Start Test terminal inside the loop, but that did not help. I put comments in the block diagram and the front panel to help identify the problem code.
    I am going to get around this problem by running this whole vi through a loop in the calling vi, where I can easily respond to button changes. This is mainly an academic or curiosity problem now.
    Thank you, Richard V
    Solved!
    Go to Solution.
    Attachments:
    Channel Setup.llb ‏286 KB

    Lets just whip up a little example then shall we?
    The subvi you see contains:
    Go ahead and run the top vi.  Press OK and watch the value of Value change (up to 20 times per second but that is faster than your eyeball).
    Why the difference between this simple example and what you are seeing?
    If I had to guess (And, I do since the caller wasn't encluded) I would suspect that you misswired the reference.  With that over-burdened connector pane and no required terminals it would be fairly easy to do.
    And thats where you might want to ricght-click the vi and deselect view as icon.
    You'll find out that its a lot easier to wire the right terminals that way.  Also, changing the terminals to "Required" for anything that is as important as an exit condition is a good idea.  Perhaps even exit if the reference is null although that should cause an error on the property node.  Did you shut off automatic error handling?.... Nope you didn't so there is a valid reference going into the sub-vi.  But a reference to what? maybe not the button you think.
    Jeff

  • Unique Index Error while running the ETL process

    Hi,
    I have Installed Oracle BI Applications 7.9.4 and Informatica PowerCenter 7.1.4. I have done all the configuration steps as specified in the Oracle BI Applications Installation and Configuration Guide. While running the ETL process from DAC for Execution Plan 'Human Resources Oracle 11.5.10' some tasks going to status Failed.
    When I checked the log files for these tasks, I found the following error
    ANOMALY INFO::: Error while executing : CREATE INDEX:W_PAYROLL_F_ASSG_TMP:W_PRL_F_ASG_TMP_U1
    MESSAGE:::java.lang.Exception: Error while execution : CREATE UNIQUE INDEX
    W_PRL_F_ASG_TMP_U1
    ON
    W_PAYROLL_F_ASSG_TMP
    INTEGRATION_ID ASC
    ,DATASOURCE_NUM_ID ASC
    ,EFFECTIVE_FROM_DT ASC
    NOLOGGING PARALLEL
    with error java.sql.SQLException: ORA-12801: error signaled in parallel query server P000
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
    EXCEPTION CLASS::: java.lang.Exception
    I found some duplicate rows in the table W_PAYROLL_F_ASSG_TMP with the combination of the columns on which it is trying to create INDEX. Can anyone give me information for the following.
    1. Why it is trying to create the unique index on the combination of columns which may not be unique.
    2. Is it a problem with the data in the source database (means becoz of duplicate rows in the source system).
    How we need to fix this error. Do we need to delete the duplicate rows from the table in the data warehouse manually and re-run the ETL process or is there any other way to fix the problem.

    This query will identify the duplicate in the Warehouse table preventing the Index from being built:
    select count(*), integration_id, src_eff_from_dt from w_employee_ds group by integration_id, src_eff_from_dt having count(*)>1;
    To get the ETL to finish issue this delete to the W_EMPLOYEE_DS table:
    delete from w_employee_ds where integration_id = '2' and src_eff_from_dt ='04-JAN-91';
    To fix it so this does not happen again on another load you need to find the record in the Vision DB, it is in the PER_ALL_PEOPLE_F table. I have a Vision source and this worked:
    select rowid, person_id , LAST_NAME FROM PER_ALL_PEOPLE_F
    where EFFECTIVE_START_DATE = '04-JAN-91';
    ROWID PERSON_ID
    LAST_NAME
    AAAWXJAAMAAAwl/AAL 6272
    Kang
    AAAWXJAAMAAAwmAAAI 6272
    Kang
    AAAWXJAAMAAAwmAAA4 6307
    Lee
    delete from PER_ALL_PEOPLE_F
    where ROWID = 'AAAWXJAAMAAAwl/AAL';

  • How do I run two while loops independent of each other?

    I have a simple VI. I have loop 1 with and LED and a stop button and I have loop 2 with an LED and stop button.  They are both in while loops.  When I run the VI,if I stop loop 1, I can not turn it back on.  If I stop loop 2, it will not stop.  I've attached a file with my VI.  
    Attachments:
    2 Loops.vi ‏9 KB

    bebesbabe,
    This looks like a learning exercise, so I will not present a complete solution.
    1. It is not polite to post to the Forum a VI which will not stop except by pressing the Abort button.  The Abort button should only be used to stop a VI if something is wrong with the program during development. Add a stop button to the outer loop.
    2. A loop with no delay will try to run as fast as possible, consuming all the CPU resources it can get. Since these loops are for user interfaces, delays of 100 to 200 ms are appropriate. Use the Wait (ms) function.
    3. Your main problem is understanding dataflow. In LabVIEW any node may execute only when all of its inputs have been given data and it will not complete its execution until all nodes inside it have completed.  Your VI does not have external inputs so waiting for data is not a factor. Each loop is considered a node. So the outer loop will iterate only after BOTH of the inner loops have stopped.  On the next iteration both inner loops will be started again.  Of course if the stop buttons are still pressed, the will stop after one iteration, which will seem almost instantaneous. But because of dataflow as I have described, your program cannot really work the way you want. You cannot restart one loop until both have stopped. Put an indicator on the "i" terminal of the outer loop.
    4. You may wish to consider changing the mechanical action on your stop buttons to Latch when Released.  Read the help to learn about mechanical actions.
    The way the instructions on the front panel read, it is not clear what the intended solution is. What control or user action or program action is required to turn the loops back on? Changing the stop button?  Automatically after a delay? A separate On switch?  How is the entire program supposed to stop?
    Lynn

  • Getting index error on ActionListener in for loop

    Hi, I am working on a little project where I want to create an array of buttons that each individually delete their record in an ArrayList, well everytime I press the delete button I get an index error, I have been toying around with it and just can't seem to find my error. Here is the code and thanks for looking:
    for(j = 0; j < records.size(); j++)
                //Set the size for the JTextFields of Names
                textname[j] = new JTextField(15);
                //Set the size for the JTextFields of Values
                textvalue[j] = new JTextField(15);
                //Create the delete button
                deletebutton[j] = new JButton("Delete" + j);
                deletebuttonaction[j] = new ActionListener() {
                    public void actionPerformed(ActionEvent actionEvent) {
                        records.remove(j);
                deletebutton[j].addActionListener(deletebuttonaction[j]);
                //Set the text for the JTextFields of names
                textname[j].setText(records.get(j).getName());
                //Set the value for the JTextFields of values
                textvalue[j].setText(records.get(j).getValue());
                //Add the textfields to the content pane.    
                contentPane.add(textname[j], BorderLayout.CENTER);
                contentPane.add(textvalue[j], BorderLayout.CENTER);
                contentPane.add(deletebutton[j], BorderLayout.CENTER);
            }

    Ok I see exactly what you're saying, now I just need to devise a plan for dealing with this index error, the only thing is that it used to work on only the first click but with the code you see there I actually get my error right away
    Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
         at java.util.ArrayList.RangeCheck(ArrayList.java:547)
         at java.util.ArrayList.remove(ArrayList.java:387)
         at GUI$7.actionPerformed(GUI.java:362)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at java.awt.Component.processMouseEvent(Component.java:6041)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
         at java.awt.Component.processEvent(Component.java:5806)
         at java.awt.Container.processEvent(Container.java:2058)
         at java.awt.Component.dispatchEventImpl(Component.java:4413)
         at java.awt.Container.dispatchEventImpl(Container.java:2116)
         at java.awt.Component.dispatchEvent(Component.java:4243)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
         at java.awt.Container.dispatchEventImpl(Container.java:2102)
         at java.awt.Window.dispatchEventImpl(Window.java:2440)
         at java.awt.Component.dispatchEvent(Component.java:4243)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Edited by: exutable on Jun 3, 2008 4:49 AM

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

    Hi all,
    I am a beginner in the Labview. I did a program that contains a while loop, its stop condition is connected to button. I selected “switch when pressed” to be the operation of this button. Our teacher asked us to make this button stops the loop if it is pressed and its name is converted to run instead of stop. And if it is pressed then again it starts the loop from the point it stopped in.
    Can anybody help me, please?

    First, please use a smaller font when composing your messages.
    You will need two while loops.  An inner loop which has its stop terminal attached to the stop button.  Put that in the False case of a case structure.  Wire a local variable of that stop button to the case selector of the case structure.  Put the case selector inside another while loop which is the one that keeps the program running no matter what the state of the original Stop button.  You will need a master stop button to stop the outer loop when you are ready to end the whole program.  Don't forget to put small millisecond waits in each of the loops so that the loops don't eat up all the CPU resources.
    For that stop button, you could rename the True title to Run, so that when it is pressed to stop the inner loop, the button will show the word Run.  Pressing it again pops it back out, allows the false case to execute and the innermost while loop to run.
    You could also change the words on the buttons by using property nodes.

  • How to run the cursor loop once even if it is true for many times - urgent

    Hi,
    Say
    loop
    tdate='12-JAN-2005'
    loop
    cursor.......
    if '10-JAN-2005'<=tdate then
    fetch
    end loop
    tdate=tdate+1 month
    end loop;
    in the above query i want my cursor to run the loop only once at the first true of my condition....in the second run the tdate will be = '12-FEB-2005'....but my cursor loop should not go in..it has to comeout....
    how to do this....plz help very urgent

    in the above query i want my cursor to run the loop only once at the first true of
    my condition....in the second run the tdate will be = '12-FEB-2005'....but my
    cursor loop should not go in..it has to comeout....Simply control has been the cursor processed or not.
    Something like that
    SQL> declare
      2    tdate date := to_date('12-JAN-2005','DD-MON-YYYY');
      3    cursor cr is select * from dual;
      4    rt dual%rowtype;
      5    cursor_has_been_processed boolean := false;
      6  begin
      7   loop
      8     if to_date('10-JAN-2005','DD-MON-YYYY') <=tdate then
      9             if not cursor_has_been_processed then
    10                     open cr;
    11                     loop
    12                     fetch cr into rt;
    13                     exit when cr%notfound;
    14                     end loop;
    15                     close cr;
    16                     cursor_has_been_processed := true;
    17                     dbms_output.put_line('Cursor has been processed');
    18             end if;
    19     --DO something
    20     null;
    21          end if;
    22     dbms_output.put_line(tdate);
    23     tdate := add_months(tdate,1);
    24     exit when tdate >= to_date('12-MAY-2005','DD-MON-YYYY');
    25   end loop;
    26  end;
    27  /
    Cursor has been processed
    12-JAN-05
    12-FEB-05
    12-MAR-05
    12-APR-05
    PL/SQL procedure successfully completed.Rgds.

Maybe you are looking for