For_Loop (loop count + indexed tunel)

Le "moralisateur intégré" (  ) de LV semble ne pas aimer une boucle For dans laquelle il y a :
- une valeur sur le "loop count"  ET   un tunnel indexé en entrée.
Pourtant il existe des cas où cela est bien utile.
Du point de vue "vitesse d'exécution", il est très intéressant de travailler sur des tableaux dont la taille est fixe et connue à l'avance par LV.
Par exemple, via un "initialize array" ou une "constante tableau". Ensuite on "agit" sur ce  Tableau  via des "replace array subset".
Résultat : Le code s'exécute sur un tableau de taille connue et  fixe.
Pourquoi ?
toute modification de la taille d'un Tableau coûte cher en temps.
par exemple ... 
via un "reshape_array" ou de façon plus indirecte (un rien plus caché) via un "delete from array"
à chaque fois que l'on "touche" (de façon directe ou indirecte) à la taille d'un tableau ... c'est payé cash en temps d'exécution.
Mais ...
même si on travaille sur un tableau de taille fixe, il est parfois nécessaire de ne traiter qu'une partie de ce Tableau.
Dans ce cas ...
une boucle For + un loop_count + un tunel indexé ... est bien utile.
Car ...
se passer du tunnel indexé d'entrée en utilisant la fonction "index array" dans la boucle ... est plus lent. (le tunnel indexé d'entrée est plus rapide)
ma question :
Bien que LV ne semble pas aimer un "loop_count" + "un tunnel indexé d'entrée" ( pourquoi ?)
existe-t-il une "réelle" contre-indication, désavantage, ou problème possible .... avec ce type de code.
Je rappelle que ... après des centaines de tests différents ... ce type d'approche me donne au final le code le plus rapide.
Réellement .. celui qui recherche un maximum de vitesse ... ne pas toucher à la taille des tableaux est un "gros plus".
merci à tous.
Résolu !
Accéder à la solution.

et oui ...
j'aurais du "voir" que cela ne pouvait pas être " truc-LabView-Manager " ...
puisque tu avais écrit  ...  la  LLVM ...
aarrgg ... pas attentif à 100% sur ce coup là ... j'aurais pu mieux faire !  

Similar Messages

  • LabVIEW 6.1 If For Loop count terminal is zero then value going through the loop is not passed on to the output of the loop

    Hello, one of our customers just encountered an execution error in a vi running under LabVIEW 6.1, which doesn't exist under LabVIEW 5.1 or 6.01. I have a simple vi that has two encapsulated For Loops. Two string arrays go in, one goes out of the outer loop. Inside the outer loop the first array is indexed. The string which results from this indexing is compared with all other strings from the second string array in the inner loop. If it matches one of the strings of the second array, it is not outputted, otherwise this string goes through the inner For Loop to the output of the inner loop and from there to the output of the outer loop. The count
    terminal of the outer/inner loop is connected to the Array Size of the first/second string array. If the second array is empty, that means that the element in test from the first arry cannot match anything from the second array, so the element in test is send to the output of the inner loop and from there to the output of the outer loop. This works fine in LabVIEW 5.1 and 6.01, but NOT in LabVIEW 6.1. In LabVIEW 6.1 the inner loop is never executed if the count value is zero (which is correct), but the data line running through the loop is not executed either, which is different to what LabVIEW 5.1 and 6.01 do. There, the input string is sent to the output of the inner loop correctly even if the loop counter is zero. The solution is easy - I just have to connect the output of the outer loop to the data line BEFORE it enters the inner loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is supposed to be a feature, but it brings some incompatibility in programming between the
    different LabVIEW versions.
    Best regards,
    Gabsi

    Hi,
    When a for-loop runs zero times, all outputs are 'undefined' (and should
    be).
    Besides, how would LV know what the output of a not executed routine should
    be?
    It might be handled differently in LV5 and LV6, which is unfortunate. In
    both cases, the result is undefined.
    It's not a bug. It's just something that should be avoided in any LV
    version.
    > The solution is easy - I just have to connect the
    > output of the outer loop to the data line BEFORE it enters the inner
    > loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is
    In some cases this does the trick. But if the data is changed in the inner
    loop, this will effect the results if the N is not zero.
    Technically, I think the output in this construction is also 'undefined'.
    But LV handles this as expected / desired.
    Another solution is to use a shift register. If N is zero, the input is
    directly passed through to the output.
    Regards,
    Wiebe.
    "Gabs" wrote in message
    news:[email protected]...
    > LabVIEW 6.1 If For Loop count terminal is zero then value going
    > through the loop is not passed on to the output of the loop
    >
    > Hello, one of our customers just encountered an execution error in a
    > vi running under LabVIEW 6.1, which doesn't exist under LabVIEW 5.1 or
    > 6.01. I have a simple vi that has two encapsulated For Loops. Two
    > string arrays go in, one goes out of the outer loop. Inside the outer
    > loop the first array is indexed. The string which results from this
    > indexing is compared with all other strings from the second string
    > array in the inner loop. If it matches one of the strings of the
    > second array, it is not outputted, otherwise this string goes through
    > the inner For Loop to the output of the inner loop and from there to
    > the output of the outer loop. The count terminal of the outer/inner
    > loop is connected to the Array Size of the first/second string array.
    > If the second array is empty, that means that the element in test from
    > the first arry cannot match anything from the second array, so the
    > element in test is send to the output of the inner loop and from there
    > to the output of the outer loop. This works fine in LabVIEW 5.1 and
    > 6.01, but NOT in LabVIEW 6.1. In LabVIEW 6.1 the inner loop is never
    > executed if the count value is zero (which is correct), but the data
    > line running through the loop is not executed either, which is
    > different to what LabVIEW 5.1 and 6.01 do. There, the input string is
    > sent to the output of the inner loop correctly even if the loop
    > counter is zero. The solution is easy - I just have to connect the
    > output of the outer loop to the data line BEFORE it enters the inner
    > loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is
    > supposed to be a feature, but it brings some incompatibility in
    > programming between the different LabVIEW versions.
    > Best regards,
    > Gabsi

  • For loop array index not from 0

    HI!
    I have an array that is wired into a For Loop. Inside the For Loop there is already a single Array content available as there is this autoindexing feature (?). I do want to change the Array from a certain position different from 0 onwards to the end e.g. change positions 4, 5 and 6 in a for loop executing 3 times. But the for loop and the autoindexing feature start at 0. Can I change this in an elegant way. At the moment I'm running thru the hole array and begin changing at a certain position.

    Yes, disable autoindexing on the tunnel and use "index array" inside the loop. Use [n]+4 as index and wire a "3" to the loop count in your particular example.
    If you want to keep the entire array and just replace a few elements with updated values, the array needs to be fed in via a shift register. Write the new elements at the desired position using "replace array subset" (see attached very simple example).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ReplaceSomeArrayElements.gif ‏3 KB

  • Loop counter

    in which system variable loop counter store

    Hi Swathi,
    The system structure have two variables sy-tabix and sy-index.
    The variable sy-tabix, for the internal tables operations. This variable holds the number of the record currently being read in an internal table loop.
    When a loop statement is executed, the system assigns value 1 for the first iteration and increases it for each new record. If we use any READ statement inside the LOOP, then the successfull READ operation changes the value of sy-tabix to the position of the required record in the read table..
    The variable sy-index is used for the iterative operations.
    This variable holds the current iteration number in a WHILE or DO loop.
    Thanks and Best Regards,
    Vikas Bittera.
    ***Points for usefull answers ***

  • SOLUTION - Re-Index Loops when "Index Now" button is broken

    This message is for anyone having trouble with Soundtrack's loop indexing in the following way:
    PROBLEM:
    ... You want to re-index some loops, or
    ... You want to de-index some loops, or
    ... Some loops are showing up red
    AND...
    ... You cannot re-index from the "Setup..." button in the Search palette (the minus button and/or "Index Now" buttons are grayed out for some unknown reason)
    *HERE IS THE POSSIBLE SOLUTION:*
    ... Delete all files from the following folders:
    Library/Preferences/Soundtrack/
    Library/Audio/Apple Loops Index/
    ... Now restart Soundtrack, and click "Setup...". All the indexed directories should be gone.
    ... You'll have to re-add and re-index your whole library. This may also affect GarageBand and/or Logic, and require re-indexing in them as well.
    *If you're still having trouble...* there may be some more index files floating around your system. Open Spotlight and set "System Files are Included" and "File Name" in the search options and search for "search index". This should show you where any remaining Apple Loop search index files are located, so you can delete them. They will be named stuff like "Search Index E44B5969-5E4A-4E27-A3C2-E5861C5D1FB8.txt".
    Hope this helps anyone else out there. It worked for me with Soundtrack 1.1 when my loops were all messed up.

    Well, to add metadata and transients to sound clips you need to edit them in Apple Loop Utility which is included with Final Cut Studio.
    To add custom loops to your permanent library you need to make a new folder like "My Loops" and put it somewhere permanent like in Library/Audio/Apple Loops and then index it with Soundtrack/GarageBand/Logic. Soundtrack uses the "Setup..." list and GarageBand you can just drag and drop into the loop browser. Not sure about Logic but it should be something similar.
    If you wanted to edit the index files manually from the Finder, they are in some weird format and I don't think it's possible.

  • Resetting a for loop counter and restarting the computation

    I have a while loop nested inside a for loop to do a calculation of a model. 
    Lets say I am on the for loop counter 4. Suppose I wanted to keep track of the number of iterations on one the while loop, and if it exceeded a certain number say 100, exit the while loop.  I am doing this to avoid my model calculation being stuck at a spot due to optimization issues. I now want to restart the calculations of for loop counter 4. 
    Is there a way to do this in labview? 
    Solved!
    Go to Solution.

    Well first of all, if you are going to restart the loop with the same program inside it after it got stuck is it not just going to get stuck again creating a permanent loop in the code? Would you not just want to move on and have some sort of identifier that one of the for-loops got stuck?
    But I would recommend simply nesting your while-loop inside of another while loop, then connect the exit for the out while-loop to some variable from the inner while-loop, so if the optimization did not occur properly then it simply repeats the inner while-loop.
    Although I stick by my thoughts that you will just end up in a permanent loop if the optimization fails the first time.

  • How to call a variable with a loop count in it

    First - I have a variable called "stages" this is a number
    that can vary. Because it can vary I want to run things in a loop
    based on the number that comes up as the stages variable amount.
    Second is a loop
    <cfloop index="riderCount" from="1" to "9">
    Next, I have a query
    <cfquery name="getPts" datasource="#application.dsn#">
    SELECT *
    FROM fantasy_racers
    WHERE proName='#pro#''
    </cfquery)
    ** Note: variable pro is set before the query **
    I have colums in my table: pts1, pt2, pts3, etc. all the way
    to pts25 for each pro in the table.
    Now to the heart of the matter
    I want to get the amount in each column. EX.: #getPts.pts1#
    but since the number of stages can vary I don't want to hard
    code for 25 outputs when there may only be 7
    so how can I call the column amount but utilize a ridercount
    in place of the number
    #getPts.pts
    ridercount#

    You can reference query variables in an array-of-structures
    notation:
    myQuery["MyColumn"][row]
    so you could do something like this:
    #getPts["pts" & riderCount][1]#
    Combine that syntax with Query.CurrentRow and
    Query.recordCount and you should be able to put a loop together
    that solves your problem.

  • Using FOR .. LOOP counter in handling of PL/SQL procedures with nest. table

    Hi all!
    I'm learning PL/SQL on Steve Bobrovsky's book (specified below sample is from it) and I've a question.
    In the procedure of specified below program used an integer variable currentElement to get reference to the row of nested table of %ROWTYPE datatype.
    Meanwhile, the program itself uses a common FOR .. LOOP counter i.
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    currentElement INTEGER;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       currentElement := p_collection.FIRST;
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element #' || currentElement || ' is ');
         IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description);
         END IF;
        currentElement := p_collection.NEXT(currentElement);
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've substituted an INTEGER global variable with such FOR .. LOOP counter, an APEX have returned an error "ORA-01403: no data found".
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element is ');
         IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description);
         END IF;
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've tried to handle this code in SQL*Plus, the following picture have appeared:
    Densely populated elements: 10
    Element is an empty element.
    Element is ID: 1 DESCRIPTION: Fax Machine
    Element is an empty element.
    Element is ID: 2 DESCRIPTION: Copy Machine
    Element is an empty element.
    Element is ID: 3 DESCRIPTION: Laptop PC
    Element is an empty element.
    Element is ID: 4 DESCRIPTION: Desktop PC
    Element is an empty element.
    Element is ID: 5 DESCRIPTION: Scanner
    Sparsely populated elements: 5
    DECLARE
    ERROR at line 1:                                 
    ORA-01403: no data found                         
    ORA-06512: at line 14                            
    ORA-06512: at line 35What's wrong in code(or what I have not understood)? Help please!

    942736 wrote:
    What's wrong in code(or what I have not understood)? Help please!First code. You have collection of 10 elements:
    1 - null
    2 - populated
    3 - null
    4 - populated
    5 - null
    6 - populated
    7 - null
    8 - populated
    9 - null
    10 - populated
    Then you delete null elements and have 5 element collection
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Now you execute:
    printParts('Sparsely populated', tempParts);Inside procedure you execute:
    currentElement := p_collection.FIRST;
    This assingns currentElement value 2. Then procedure loops 5 times (collection element count is 5). Element 2 exists. Inside loop procedure executes:
    currentElement := p_collection.NEXT(currentElement);
    which assigns currentElement values 4,6,8,10 - all existing elements.
    Now second code. Everything is OK until you delete null elements. Again we have:
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Again you execute:
    printParts('Sparsely populated', tempParts);Now procedure loops 5 times (i values are 1,2,3,4,5):
    FOR i IN 1 .. p_collection.COUNT
    Very first iteration assingns i value 1. And since collection has no element with substript 1 procedure raises no data found.
    SY.

  • Error in sql query as "loop has run more times than expected (Loop Counter went negative)"

    Hello,
    When I run the query as below
    DECLARE @LoopCount int
    SET @LoopCount = (SELECT Count(*) FROM KC_PaymentTransactionIDConversion with (nolock) Where KC_Transaction_ID is NULL and TransactionYear is NOT NULL)
    WHILE (
        SELECT Count(*)
        FROM KC_PaymentTransactionIDConversion with (nolock)
        Where KC_Transaction_ID is NULL
        and TransactionYear is NOT NULL
    ) > 0
    BEGIN
        IF @LoopCount < 0
            RAISERROR ('Issue with data in KC_PaymentTransactionIDConversion, loop has run more times than expected (Loop Counter went negative).', -- Message text.
                   16, -- Severity.
                   1 -- State.
    SET @LoopCount = @LoopCount - 1
    end
    I am getting error as "loop has run more times than expected (Loop Counter went negative)"
    Could any one help on this issue ASAP.
    Thanks ,
    Vinay

    Hi Vinay,
    According to your code above, the error message make sense. Because once the value returned by “SELECT Count(*)  FROM KC_PaymentTransactionIDConversion with (nolock) Where KC_Transaction_ID is NULL and TransactionYear is NOT NULL” is bigger than 0,
    then decrease @LoopCount. Without changing the table data, the returned value always bigger than 0, always decrease @LoopCount until it's negative and raise the error.
    To fix this issue with the current information, we should make the following modification:
    Change the code
    WHILE (
    SELECT Count(*)
    FROM KC_PaymentTransactionIDConversion with (nolock)
    Where KC_Transaction_ID is NULL
    and TransactionYear is NOT NULL
    ) > 0
    To
    WHILE @LoopCount > 0
    Besides, since the current query is senseless, please modify the query based on your requirement.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to get count,index and compare to arraylists

    hi
    how to get count,index and comparing of 2 arraylist.... plz suggest me asap...

    How is your question related to JDBC? And what have you done so far with your code?

  • Storing data in a new excel sheet for each loop count

    I have a data acquisition code that takes data from the oscilloscope and saves it in an excel file.
    The oscilloscope has to take data at different instants(at each loop count). At each instant, the data gets appended to the same excel sheet. I just wanted to know if there is a way so that each time the data gets stored in a new excel sheet......
    If I run the vi again, the data is stored in a new excel sheet. But in a single run of the vi, all the data is always stored in a single excel sheet. Can anyone please help me with this??
    Thanx. 

    i have used write to measurement file.
    An image of a part of the code is attached.
    thanx... 
    Attachments:
    abc.jpg ‏25 KB

  • Loop counter reset in parallel model ?

    Hello,
    i am using TestStand 3.1 with parallel model. There is a loop counter for each UUT in RunState.Root.Parameters.TestSocket.UUT.UUTLoopIndex. This increases with every loop that is done.
    Now my problem is: If i start the NextUUT, this counter is not set to 0. It just increases.
    Is there a different counter that i can use ? Or where can i get the information that the NextUUT button is pressed so that i can reset the counter manually ? Or is there another solution.
    Thanks for Help.

    Hi,
    I don't completely understand, why you want to reset the UUTLoopIndex, because it shows the number of iterations per test socket to check how many uut's have been tested on each. However, you could reset the value with a simple statement before you start the tests. You could do this in the setup step group, e.g. with RunState.Root.Parameters.TestSocket.UUT.UUTLoopIndex = 0. You could add a message popup or evaluate an extra condition or so.
    Kind regards,
    Philippe Goetz,
    Applications Engineer, National Instruments

  • Loop count in FPGA

    Hi ,
    Could anyone please suggest me what's wrong with this as marked in the attachment.
    My goal is to measure every loop count and display those numbers in the indicator as shown.
    Please respond quick.
    Thank You.
    Attachments:
    iteration count.jpg ‏157 KB

    Hi,
    If you put the indicator inside of the loop then it will continuously update. Because it is outside of the loop, it will update with the final iteration count when you exit the loop.
    Thanks,
    Paul B.
    Motion Control R&D

  • Operation loop count

    Is there a way to over-ride an operation loop count.  I have an SFC that has met the limit but I would like to over-ride and process the sfc through the operation.
    I see an NC over-ride but can not find anything on Operation.

    The loop count is in the same place as the NC overide.  You should find loop count in the drop down box with the NC Code.  To overide use details on the operation.

  • Count Index Internal Table or Select Statement

    Hi All,
    I wish to index and display my internal table. How do i do this? for example in my Internal Table I have the following data:-
    Material-----Plant--Index
    ABCD1--  1000--
    1
    ABCD1--  1000--
    2
    ABCD1--  1000--
    3
    ABCD2--  1000--
    1
    ABCD2--  1000--
    2
    Basically based on the unique values in Material and Plant an Index is generated? does that make sense?
    Thanks
    Adeel

    Hi Guys,
    Tried them it doesn't seem to work. I might try a different approach. i have the following loop.
    What i am trying to do is bring the last price of an entry from itab and storing this in itab. Example
    *Material----
    Price----
    Previous Price*
    ABC1  -
    £10----
    £0 (as this is the first record)
    ABC1  -
    £30----
    £10
    ABC2  -
    £15----
    £30 *<----
    ERROR*
    ABC2  -
    £45----
    £15
    So basically it is working exactly how i want it apart from when there is a new Material it isn't clearing the previous price even though there is no previous price....does that make sense? I was thinking of doing something via counting etc... but you guys might know an easier solution. Code is below how can i clear the previous price using the example above.
    Please note this code does exactly what i want apart from clearing the previous price if it doesn;t exist.
    LOOP AT itab.
      MOVE sy-tabix TO chnge.        " sy-tabix counts no of records.
      IF sy-tabix > 1.
        w_num = sy-tabix.
        w_num = w_num - 1.
      MOVE konp-kbetr TO itab-price.
      ENDIF.
    ENDLOOP.

Maybe you are looking for