Bug in conditional for loop with an empty array

There appears to be a bug in the for loop with a conditional terminal.
If an empty array is wired to an auto-indexed array input tunnel, an output array tunnel has one element instead of zero.
The array constant on the left is empty.
Top loop without the conditional terminal produces an empty array.
The bottom loop with a never true conditional terminal produces an array with one element
Using LabVIEW version 8.5
Message Edited by TrevMrgn on 05-05-2009 02:01 PM
Solved!
Go to Solution.
Attachments:
For loop bug.png ‏3 KB

Creating the example from scratch, I do not see the error.
Neither do I.
If I add one or more elements to the array (constant or control), then delete them all (using 'Delete Element') the bottom array has one element.
Nup. Still empty.
If I empty the array (using 'Empty Array') both are empty.
Yep.
Also if I create an empty array using 'initialise array' with zero elements, I get one element.
Nup. Still empty.
'Show constant folding' does not appear to change the behaviour, but including a random operation in the loop does.
Agreed that constant folding doesn't cause any odd behaviour. Introducing a random operation (adding two constants) in the loop doesn't either.
I've tried all your methods here Trevor, but I can't replicate this behaviour in 8.5.1 under WinXP SP3. Sorry!
 Maybe somebody else will be able to help, or find a useable workaround.
Thoric (CLA, CLED, CTD and LabVIEW Champion)

Similar Messages

  • Display a message in a For Loop  with field value

    Hello All,
    pls,i wanna display a message in a For Loop with field value the code is:
    FOR Q1 IN GET_SUM_EXP_QUANTITY LOOP               .
    INSERT INTO PLN_PLAN_DISTRIBUTION_WAY
    (FIN_YEAR_CODE , MONTH_CODE , MATERIAL_CODE , DISTRIBUTION_WAY , EXPECTED_QUANTITY , GROUP_CODE)
    VALUES (:PLN_PLAN.FIN_YEAR_CODE , TO_CHAR(V_FROM_DATE,'MM') , Q1.MATERIAL_CODE , 1 , V_MONTHLY_QTY , Q1.GROUP_CODE);
    MESSAGE(':PLN_PLAN.FIN_YEAR_CODE'||:PLN_PLAN.FIN_YEAR_CODE ||' '||'V_FROM_DATE = '||TO_CHAR(V_FROM_DATE,'MM'), 'Q1.MATERIAL_CODE'||' '|| Q1.MATERIAL_CODE||' '||'DISTRIBUTION_WAY'||' = 1'||'EXPECTED_QUANTITY'||' = '|| V_MONTHLY_QTY||'GROUP_CODE'|| ' '|| Q1.GROUP_CODE);
    FORMS_DDL('COMMIT');
    How 2 display a message with the value:
    Q1.MATERIAL_CODE
    Q1.GROUP_CODE
    message(Q1.MATERIAL_CODE)     
    gave me numeric or value error on run time when pressed on button
    Regards,
    Abdetu..

    Thanks 4 reply..
    again they r in a For Loop as mentioned above...
         INSERT INTO PLN_PLAN_DISTRIBUTION_WAY
                                                           (FIN_YEAR_CODE , MONTH_CODE , MATERIAL_CODE , DISTRIBUTION_WAY , EXPECTED_QUANTITY , GROUP_CODE)
                                            VALUES (:PLN_PLAN.FIN_YEAR_CODE , V_REPAIR_MONTH , Q1.MATERIAL_CODE , 1 , V_REPAIR_Qty , Q1.GROUP_CODE);
    FORMS_DDL('COMMIT');
    The fields in bold r required to be displayed for testing puposes..
    this gives me numeric or value error in runtime..
    Best regards,
    Abdetu..

  • Help with a FOR loop and an object array

    I need to make a for loop that takes an array of objects that contain the parameters year, type, and model (all ints) and sort by year, then divide the array in all the objects with the same year and sort them by type, then divide the array again into the objects with the same year AND type and sort them by model.
    the object a Dress objects, the get methods are get+nameof parameter.
    the array is a 1D array called Dresses.
    I have made a paralell array to store the value of the parameters and sort that then move the array acording to that sorted array. The problem is in the division of the array.

    We'll give your request to do (or finish) your homework for you the attention it deserves.

  • The demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.

    the demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.
    your recommended second option that i could add true/false case.
    this true/false case must be inside the for loop or outside the for loop?if this case is inside the for
    loop, how can i send stop command from outer while
    loop?
    more over do you have any example for this please?
    thanks"

    You can execute a fixed number of iterations using a while loop by comparing the iteration count to the number of iterations you want and wiring the output of that comparison (e.g. Less Than or Equal To) to the continue (or stop) terminal of your while loop. Which comparison you use depends on personal preference, where you wire the desired count and the interation count, and whether you're using the while loop as Continue if True or Stop if True.
    Ben gave you step-by-step instructions in response to your previous question. Look here for Ben's response.
    Ben's response looks pretty good and detailed to me. It certa
    inly deserved better than a 1-star rating.

  • Using a For loop to call one array element at a time

    I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.
    Adam

    adamoutlaw wrote:
    Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
    I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
    Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
    Message Edited by altenbach on 08-02-2007 07:14 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Indexing.png ‏4 KB

  • For Loop exits prematurel​y - Arrays and Shift Registers

    I have attached some preliminary code (work in progress) for the RC4 encryption algorithm. For some reason the middle for loop exits prematurely. In other words it exits after 2 iterations instead of the 256 iterations that N is set to.
    I thought this was not possible and therefore I am presuming I have made some not so obvious error in attempting to use a shift register with an array.
    Please have a look. Thanks.
    Attachments:
    RC4 Encryption beta.vi ‏78 KB

    You misunderstand how a for loop operates. You can either wire a number to the N terminal or you can wire an array into it with auto-indexing turned on. With an array input, the for loop will iterate equal to the size of the array. When you wire both (a practice I do not recomend), the for loop will iterate to whichever is smaller - the array size or the N terminal. Both of your for loops on the left side is creating arrays with only two elements. I suspect that what you need in both of them is a shift register instead of exiting the for loop with auto-indexing turned off.

  • About condition for loop in BPM

    I design a loop, condition is counter<>3.
    It seems only receives 3 messages when I send more than 3.
    for example, I send 105 messages, for every 10 messages it will generate a file. and I totally have 11 files.
    What is the best way to end the loop?

    Hey,
           you need to have two loops in this.
           Have your send step(for the file) in the inner loop.
            The condition for this loop will be te number of messages that you need per file.
          The outer loop should terminate when all the messages are recieved.(recieve step will be in the outer loop)
       This is not possible with the no. of messages
    You can do one thing, provide a stop message as an input along with the other messages.
    And set the condition for the outer loop for the stop message.
    This will terminate the outer loop.
    regards,
            Milan

  • For Loop with parameter in application process

    Hello,
    I am working on a project for school and a loop in an application process is giving me a headache. I have an application from which I make an ajax call to an "on-demand" process. Here's a short version of the process:
    declare
    valuesList varchar2(32000) := '';
    sqlWhere varchar2(32000) := '';
    begin
    begin
    //calculations, but let's hard code sqlWhere for demonstration purposes
    sqlWhere := ' where ID = 50';
    for j in (select * from myview sqlWhere) loop
    valuesList :=valuesList || '~rowsep~' || j.id || '~colsep~' || j.beds;
    end loop;
         exception
         when no_data_found then null;
         when others then HTP.p('Error: ' || SQLERRM);
    valuesList := substr(valuesList, 9, length(valuesList));
    end;
    htp.prn(valuesList);
    end;
    I thought the for loop would contain only one record but it lists all records in the view. Interestingly, when I replace the loop condition to 'select * from myview where ID = 50' it returns what it's supposed to.
    Could someone please explain what I am doing wrong?
    Thank you!

    There are a couple of different options but using a variable in the sql statement and not the where clause needs an execute immediate. The link below gives a good overview and options to accomplish what you are trying to do.
    execute immediate with for loop
    Edited by: tread on Apr 23, 2012 1:09 PM

  • For Loop with Error Check

    Hello all,
    As per my sample VI.
    I gave   Empty array to For Loop. As we know this Loop will not execute because N value “0”.
    But, I want to know why Error out always giving True value. This Error Indicator value changing to “True” irrespective of Error In.  
     BR,
    Munna
    Munna
    Solved!
    Go to Solution.

    That''s exaclty what I said.
    If you use plain tunnels and the loop iterates zero times, the output will give the default value for the datatype, which is FALSE for errors.
    If you use shift registers, whatever is wired to the initializer terminal will be output unchanged on the right if the loop iterates zero times. Since you initialize with a error=TRUE, that's what you get.
    This is all as expected. In your first post you claimed that the output is error=true using plain tunnels, which cannot be. Agreed?
    If you want error=false with the shift register, change the diagram constant accordingly.
    LabVIEW Champion . Do more with less code and in less time .

  • Help needed with 'Conditions' for field with read only on demand

    Hy guys,
    I really need your help now, i have two items named P22_LOGIN_TYPE (..wich can be 'Default' or 'Special') and P22_PASSWORD, i need to turn to 'read only' the second item when the first item is 'Default', i'v tryied the conditional option but with no success, i know is managed from there but it's not working for me, it seems that i don't know exactly how to do it. By the way, i have APEX 2.2.
    I need an exact guide (explanation) on how to do it, thank you very much.
    Best regards,
    Victor

    Firstly you could set your First item to be a select list with submit. Make the branch go to the same page.
    Secondly, on the read-only conditions for your second item, use the condition when item in expression 1 = value in expression 2, and set that to 'Default' in expression 2.
    Essentially this will re-submit your page when you make a selection either 'Default' or 'Special'. If 'Default' is selected, then the PASSWORD item will be rendered as read-only. If you don't want to display the PASSWORD item at all, you can put the above condition for the read-only, into the conditions section of the item.
    Hope this helps and is not too confusing. It reads a lot worse than it actually is ;)
    Cj

  • Output Conditions for Header- with Item criteria

    Hi!
    We want to set up the Output conditions for delivery note per storage location.
    SAP has problems with reading it on the header level- as it is only on LIPS. Is there any easy workaround so it picks up the item field?
    Thanks!!
    Cheers
    Bea

    Hello Bea
    You may be able to acheive  this by doing the following:
    1) Add the field 'Storage Location'  (LGORT) to the filed catalog for output with the following activities:
         SPRO/IMG/Logistics Execution/Shipping/Basic Shipping Functions/Output Control/System Modifications for Output/New Fields
         For Output Control
    2) Then create a condition table for the new access:
       SPRO/IMG/Logistics Execution/Shipping/Basic Shipping Functions/Output Control/Output Determination/Maintain Output
       Determination for Outbound Deliveries/Maintain Condition Tables
    3) Then add the new condition table to the requisite access sequence:
       SPRO/IMG/Logistics Execution/Shipping/Basic Shipping Functions/Output Control/Output Determination/Maintain Output
       Determination for Outbound Deliveries/Maintain Access Sequences
    Please review OSS note 756688 which says that  you need to 'go to the item output screen before saving the document the header output is found'.
    It may be worthwhile to remain an output at item level with the same access also.
    OSS note: 756688 - Access sequence with item and header fields
    Hope this helps.

  • How to use for loops with Multiple Initializers and Incrementers

    I found that my for loop is printing out wrong, because I am using two for loops. I have searched but all I can find out is you can't use multiple inializers and increments, does anyone know how to get around this? How would I use an array for this?
    Thanks very much for your help.
    import java.util.Random;
    import java.util.Arrays;
    /** Generate numnodes value for random integers in the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range 0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    }

    Sorry that code works, but I want to use both my x and y coordinates to get a random number from 0 to 499 in both of them, then I want to do some comparisons of the values, then return it to another function. As it stands now, I get the wrong results when I run it, as you can see at the bottom.
    Thanks very much for your help. I have been stumped all mornign on this and have looked everywhere trying to find an example. I don't won't to use math random. I am on a tight deadline to finish and at the rate I am going, I will not complete it.
    /** Generate numnodes value for random integers in
    the range 0..499. */
    public final class RandomInteger {
    public static final void main(String... aArgs){
    log("Generating 6 random integers in range
    0..499.");
    int numnodes = 6;
    //Randomly generate a number between 0 and 499 for
    the x and y coordinates for the nodes
    Random randomGenerator = new Random();
    for (int x = 0; x < numnodes; ++x) {
    int randomInt = randomGenerator.nextInt(500);
    Random randomGenerator2 = new Random();
    for (int y = 0;y < numnodes; ++y) {
    int randomInt2 = randomGenerator2.nextInt(500);
    log("Generated : " + randomInt + " " + randomInt2);
    log("Done.");
    private static void log(String aMessage){
    System.out.println(aMessage);
    Output:
    --------------------Configuration:
    <Default>--------------------
    Generating 6 random integers in range 0..499.
    Generated : 98 254
    Generated : 98 347
    Generated : 98 359
    Generated : 98 25
    Generated : 98 277
    Generated : 98 148
    Generated : 416 401
    Generated : 416 165
    Generated : 416 354
    Generated : 416 169
    Generated : 416 144
    Generated : 416 354
    Generated : 295 158
    Generated : 295 138
    Generated : 295 349
    Generated : 295 324
    Generated : 295 18
    Generated : 295 193
    Generated : 197 451
    Generated : 197 416
    Generated : 197 480
    Generated : 197 33
    Generated : 197 490
    Generated : 197 494
    Generated : 324 412
    Generated : 324 490
    Generated : 324 213
    Generated : 324 386
    Generated : 324 467
    Generated : 324 163
    Generated : 379 180
    Generated : 379 446
    Generated : 379 314
    Generated : 379 52
    Generated : 379 113
    Generated : 379 271
    Done.
    Process completed.

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

  • Dynamic component in WHERE-condition for LOOP AT ?

    i want to make
    loop at itab where  (dynamic field) > 0
    how i can make it...
    Edited by: Thomas Zloch on Mar 2, 2010 2:47 PM

    I thought it's funny.
    And the problem can maybe be solved by using a completely dynamic where-condition, not just a dynamic component.
    http://help.sap.com/abapdocu_70/en/ABAPLOOP_AT_ITAB_COND.htm#!ABAP_ADDITION_4@4@
    Thomas
    P.S. meaningless subject enhanced, and please take the time to say hi and please when asking for help. Thanks.

  • Enhanced for loop with DirectoryStream  in java 7

    Hi, I'm a newbie to Java and am having trouble with the following code, which I'm trying to use to iterate through a directory and obtain the file names of all the pics to create thumbnails of them.
    I've done hours and hours of searching on the web and find no answer for this one, so it's probably something very simple I've screwed up.
    All assitance is appreciated.
    The code segment:
            try (DirectoryStream<Path> ds =
              Files.newDirectoryStream(FileSystems.getDefault().getPath(dirNew)))
                  System.out.println("at dirstream");
                  System.out.format("toString: %s%n", ds.toString());
                for (Path p : ds)
                    // Iterate over the paths in the directory and print filenames
                   System.out.println(p.getFileName());
                   System.out.println("at Path p : ds");
                    thumbName = p.getFileName();
                    createThumb(String.format("%s",thumbName));
            } catch (IOException e) {
                System.out.println("dirstream failed!!!");
    //           e.printStackTrace();
                System.out.println("atend of dirstream");and the output:
    run:
    /home/rich/Images/FromWeb-Misc/1
    at dirstream
    toString: sun.nio.fs.UnixSecureDirectoryStream@196b20e
    atend of dirstream
    Edited by: 898552 on Mar 6, 2013 3:04 PM
    Edited by: 898552 on Mar 6, 2013 3:07 PM
    Edited by: 898552 on Mar 6, 2013 3:09 PM

    rp0428 wrote:
    >
    It's not entering the loop.
    >
    With the versions of NetBeans I use you can set breakpoints BEFORE and even ON the loop! Being able to set them inside a loop is just a no-cost extra. ;)I know! But you said "IN THE LOOP" :D The poor guy will set his breakpoint in it and think his debugger is broken ;)
    Relax - take a deep breath - repeat after me
    >
    5 more points - 5 more points - 5 more points
    >
    Congratulations - I see a 'shiny' future for you!
    Status Level: Expert (2,495) :DHaha, I hadn't noticed that :D I better be extra helpful now, so I can pop open a bottle of champagne tonight ;)

Maybe you are looking for

  • Lumia 1520 error code 8018830f

    Downloading the update can't install the message " the update was downloaded but can't be open" Tried to change language no change. Any other options ? Boaz Solved! Go to Solution.

  • Unable to isync palm Z22, failing on ical

    just got a new palm z22, set up for isync. i've got Mac OSX 10.3.9, isync 1.5, ical 1.5.5(v670). in hotsync conduit manager, for isync conduit, checked "enable isync for this palm device". when i do sync, it takes forever the first time (as expected)

  • Flicker Removal in Premiere Elements 12

    The  option for Flicker Removal only allows you to add Flicker Removal to one clip at a time.  This is very time consuming if you have many clips.  Is there anyway to highlight all of the clips at the same time? 

  • Multi selection N rows and N Columns

    i am using ADF 10g jdeveloper 10.1.3.5 i want make multi selection(Check box) in 3 row and N columns depend on size of iterator, can give example or ..... thanks

  • Photoshop cannot open files in the "Adobe Photoshop JPEG file" format

    Strange intermittent issue on Mac, 10.6, CS4. Anyone know what happens to standard image files that makes them so PS cannot open them? Thanks ~AC