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

Similar Messages

  • How to let " i " of a for loop to start from a "X"

    Hi,
    how to let " i " of a for loop to start from a value "x" where x is a variable?
    Thx
    Message Edited by starfish on 10-19-2007 06:00 AM

    Hi starfish,
    use it like this:
    If this doesn't fit your needs you should attach an example of what you really need!
    Message Edited by GerdW on 10-19-2007 01:15 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    I.png ‏2 KB

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

  • Issues with nested for loops - saving images from a camera

    Hi all,
    I've written a vi. to capture a specific number of images ('Image No') and save these images, outputted to a folder of my choice.  Each image is identified sequentially.  However, I wish to do a number of iterations ('Run') of this capture sequence, such that the filename of each image would be 'Filename (Run)_(Image No).png', e.g. run 5, image 10 would be 'Filename 5_10.png'.  I have tried a nested for loop for this but I receive an error 'Asynchronous I/O operation in progress' (I've attached a printscreen).
    Can anyone assist me in solving this problem? I preiously posted this in machine Vision but got no response (http://forums.ni.com/t5/Machine-Vision/Capturing-image-sequences-issues-with-nested-for-loops/m-p/19...).  Please find attached my vi.
    Kindest regards and thanks,
    Miika
    Solved!
    Go to Solution.
    Attachments:
    Labview problem.jpg ‏3841 KB
    Image sequence save to file.vi ‏48 KB

    Miika,
    the problem is not the filenam, but the name of the folder (AHHHHH!). You try to create the same folder in the outer for loop over and over again.... (it is the error message above the '======', not below )
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • How to recover the for loop or seq() from a sequence result

    assume generate a sequence with code
    for i in 1..2 do
        append 1 to a list to represent outer loop
        for j in 1..3 do
               append 2 to list to represent inner loop
    result in [1,2,2,2,1,2,2,2]
    is it possible to recover for loop code and seq() function code from [1,2,2,2,1,2,2,2] ?
    with fold or unfold or other method?
    computing nightmare

    Yes; and in doing so, your program will converge towards being an exemplar of the generalization of
    Greenspun's tenth rule to any arbitrary language (rather than just 'C' or Fortran).

  • 404 Error (not found) for webfragment when running from OEPE (split source)

    For a large project, we are developing several JSF modules as JARs which then become packaged inside a single WARs WEB-INF/lib, which in turn will be the only substantial part of an EAR.
    When I build with maven / run from command line, everything works fine.
    But when I run from OEPE using the split source structure (actually also when I run from command-line using the split source structure that OEPE has generated), all the JSF in the JARs are not found anymore, and I get a 404 Error in the browser.
    I can reproduce the problem with a minimal set of almost-empty Eclipse projects (one WebFragment, one WAR, and an autogenerated EAR).
    (too bad I can't attach it here)
    The generated .beabuild.txt is as follows:
    C\:/workspaces/weblogicear/WebFragmentWAR/WebContent = WebFragmentWAR.war
    C\:/workspaces/weblogicear/WebFragmentWAR/build/weboutput = WebFragmentWAR.war
    C\:/workspaces/weblogicear/WebFragmentWAR/build/classes = WebFragmentWAR.war/WEB-INF/classes
    C\:/workspaces/weblogicear/WebFragment/bin = WebFragmentWAR.war/WEB-INF/lib/WebFragment.jar
    Under WebFragment/bin/META-INF/resources I have an index.xhtml, which is not found by Weblogic's implementation of ExternalContext.
    See also this thread (without answer): When web apps/war published via OEPE I get '404 Not found' on access I don't know if the original poster had the same problem. I tried to reply there, but my reply doesn't show up.

    > The Testing Server Folder is:
    D:\Inetpub\wwwroot\Zero-ten\www\
    > The URL prefix is:
    http://localhost/zero-ten/www/
    > Is that the problem?
    In the testing server folder you have a CAP Z
    in the URL prefix you don't have a cap.
    Also, would need to know more about your testing server
    (what type) if there are additional problems.

  • How to put entries in a for loop without hard coding the values

    I have a below pl/sql block that needs to flag a claim based on claim number values given that I have in an excel sheet. Is there a way to capture those 500 claims efficiently in the select statement in the pl/sql without hardcoding these from value 1 ...to value 500 (as listed below)???
    DECLARE
       ln_ctr   NUMBER := 0;
    BEGIN
       FOR lrecclaimnumber
       IN ( SELECT   entityid claimnumber
             FROM   mpi_fnx.wfTokenEntity wte
            WHERE   wte.entityid IN
                          ('Value1','Value2',....'Value 500')
    LOOP
       mpi_fnx.pkgSaveClaimData.spMarkClaimInvalid (pivClaimNumber          => lrecclaimnumber.claimnumber,
                                                    pininvalidreasonid      => 304,
                                                    pinuserid               => 4999
       ln_ctr := ln_ctr + 1;
       END LOOP;
       DBMS_OUTPUT.put_line ('Total Entries Processed: ' || ln_ctr);
    END;
    /

    DECLARE
       ln_ctr   NUMBER := 0;
    BEGIN
       FOR lrecclaimnumber
       IN ( SELECT   entityid claimnumber
             FROM   mpi_fnx.wfTokenEntity wte
            WHERE   wte.entityid IN
                          (select 'Value '|| level as col_name from dual  connect by level <=500)
    LOOP
       mpi_fnx.pkgSaveClaimData.spMarkClaimInvalid (pivClaimNumber          => lrecclaimnumber.claimnumber,
                                                    pininvalidreasonid      => 304,
                                                    pinuserid               => 4999
       ln_ctr := ln_ctr + 1;
       END LOOP;
       DBMS_OUTPUT.put_line ('Total Entries Processed: ' || ln_ctr);
    END;
    / bye
    TPD

  • Functions in a For Loop defining objects from an Array. . .Why Won't This Work?!

    I'm trying to put these functions into a Loop to conserve
    space. Why won't this work?
    .

    Yeah, sly one is right. You can not have the "i" inside the
    onRollOver function, what you have to do is: As the movieClip class
    is dynamic you can create a property of the movieClip which stores
    the value if the "i". And then, inside the onRollOver function, you
    have to make reference to that property.
    for (i=0; i<2; i++) {
    this.regArray
    .iterator = i;
    this.regArray.onRollOver = function () {
    showRegion(regArray[this.iterator]);
    this.regArray
    .onRollOut = function () {
    hideRegion(regArray[this.iterator]);

  • What's the best Preferred Execution System setting for parallel testing run from TestStand

    I configured what vi's I think need to be reentrant, but I am not sure what choice for "Preferred Execution System" is best for the vi's in my TestStand sequence that's going to run in parallel.  Can anyone advise?
    Thanks!

    Hi mike_22,
    This option should not matter unless you have a LabVIEW VI with parallel code blocks.  If this is the case, you can set your VI to Other 1 or Other 2.  Please take a look at this knowledgebase for further explanation.
    Cheers,
    Kelly R.
    Applications Engineer
    National Instruments

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

  • How to ignore error and continue with next value in PL/SQL FOR loop?

    hi,
    When the DROP INDEX statement fails it have to continue with the next value in FOR loop without exiting from the loop. Can anyone tell me how to do this?
    DECLARE
    CURSOR aud_cur IS
    SELECT key_col_idx FROM audience_work where aud_ref_id between 106 and 109;
    BEGIN
    FOR aud_row IN aud_cur LOOP
    EXECUTE IMMEDIATE
    'DROP INDEX ' || aud_row.key_col_idx;
    END LOOP;
    END;
    Thanks,
    Noble

    DECLARE
      CURSOR aud_cur
      IS
      SELECT key_col_idx FROM audience_work where aud_ref_id between 106 and 109;
    BEGIN
      FOR aud_row IN aud_cur LOOP
        begin
          EXECUTE IMMEDIATE 'DROP INDEX ' || aud_row.key_col_idx;
        exception
          when others then
            if sqlcode = -01418 then
              dbms_output.put_line(' index does not exist ');
            else
              dbms_output.put_line(sqlcode);
              raise;
            end if; 
        end;
      END LOOP;
    END;
    /

  • 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

  • Question about using for-loop to generate array from DAQmx. Thanks!

    I have a laser system with a frequency of 1kHz, I am using this 1kHz signal to trigger the DAQmx and get the data from a photodetector, e.g. I will get 1000 data points during 1 second from DAQmx, but I need to separate this 1000 data points into the even and odd list, which is two list of 500 data points, e.g.. The 1st, 3rd, ... 99th data is one array, the 2nd, 4th,... 10th data is another array, then I will do further calculations based on these two arrays.
    To seperate the even and odd data, the only way I can find is put these 1000 points into an array and then seperate them afterwards.
    Can I do things like this pic?
    I don't know the speed of the for loop, because the 1kHz trigger is always there, once it is triggered, the DAQmx read will give a data point, if the speed of the for-loop( the time from the end of a loop to the beginning of the next loop) is slower than the 1kHz trigger, then the for-loop will miss data point, then the ordering of the 1000 points in 1 second will be changed.
    Or I need to put everything, e.g. AI Voltage, Trigger, sample clock, into the for-loop and then return a Y? Thanks! 

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

  • I need to take elements from within 2 nested for loops and place them in an array at the specific row and column that I need.

    I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
    oes keep re-initializing my array.
    Attachments:
    Untitled.vi ‏26 KB

    I have fixed a number of things in your vi.
    You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    your_vi.vi.zip ‏13 KB

  • For loop help from 1 to z

    hey guys anybody know how would i set a for loop to go from 1 to z. I want to print it out.
    for (int x= 1; ___?___; x++)
    System.out.println(x);
    thanx

    No, that won't work... you'll never iterate at z because z is not < z. The proper code would either be
    for(int x = 0; x < z; x++)or
    for(int x = 1; x <= x; x++)...depending on your style.

Maybe you are looking for

  • I can't get my Itunes to connect with the itune store . my itune will not go on line

    I down loaded the latest Itune and it will not connect to the internet. when i do a diagnostic it tells me there is live connection but it will not connect to the itune store

  • On launch Mail's first outgoing email takes 3 minutes to send.

    Every time I launch Mail in Snow Leopard, the very first outgoing email takes FAR too long to get out. All the following emails seem to go out normally. This happens to all Mac's on my network that have upgraded to Snow Leopard. A friend running Tige

  • Software on vista for x-fi

    A free CD containing the full application suite will soon to be available to order from our Online Store (a Shipping & Handling charge will apply). What is this? Can't we download new , on your ftp?Are we must buy software cd ? This cannot be We want

  • ISA_Rs_db Database which tables contain logging data?

    I am working first time on TMG Server and Database.  user gave me .W3C file  which is very large enough (3GB)file which can not open in notepad or word.  i can not load into SQL Server Database using SQL import wizard . throwing errors I have this IS

  • How to maintain Document Type as Default in FB60

    Hi Gurus, How to maintain Document Types. I have a requirement in Transaction FB60 that Document Type should be Vendor Invoice as Defualt whenever i open this T.Code. (Now Cash Book - HO, coming as defualt in FB60). So please tell me from where i can