For loop within a while loop

I have for loop within a while loop... admission to the for loop N comes from the VI selection... the while loop I a condition essentially statement it stops just after to finish all the iteration in loop...

Entrance to the N loop is bascially driven by a local variable... that's the problem Iam having:

When I press the Start button to run the program... regardless of the output of the select VI is gives the N of the for loop, then the loop starts and then ends in place... and when the output of the select statement takes a different value (the N of the loop for) loop not work until I restart the program again... What can I do so that the for loop runs again for another value of N, the RUN program button is enabled.

1. clean your diagram.  Style guides suggest keep the pattern of a single screen.  With a little effort, I was able to get your DB less than 1600 x 1000 pixels.

2 then I can see (some) it happens all at once. This thing does nothing?

3. local variables can lead to race conditions.  Output in Angle position may be a race condition, although is probably not what you wanted to do.  What does the wired local time at the moment present terminal meter? (Ooops! Two controls with the same name - which can be quite confusing as well!)  If you need or want two components of façade having the same text, use the legends.  Make the labels is different so the comic is more readable.

4. having more than one Dequeue function on the same queue will lead to unpredictable results.  When an item is removed, it is removed from the queue and is not accessible to any other Dequeue function.  In parallel loops, you have no way of guessing which Dequeue will seize any particular element.

5 use Boolean reverse instead of Select with wired False to true and true cable at the entrance to false entry. Better, just make the case of forgery in the structure of the case within the for loop the real deal. No required reversal.

6. I was not looking for to determine the logic of the code within the structure of this case. It seems I could have posted a much simpler way to do this several weeks ago.

7. use multiply from the Digital Palette rather than a node form multiply by 4 or 1.8. Uses less space BD and is much easier to read.

8. as has been suggested, learn how to work the machine architecture and the State of producer/consumer.  They can make your life much easier.  Do not try to convert immediately to these models.   It's too much bite to at some point.  Learn how they work first.  Make a few simple examples.  Then rewrite this program in this format.  Probably faster than fixing what you have now.

Lynn

Tags: NI Software

Similar Questions

  • Is it possible to execute a loop For independently within a while loop in LabVIEW 2013?

    In my program, I want to run a loop For inside a while loop and run independently, at their own rate of execution.  A test, I wrote a simple VI with a while loop with 1 second calendar and in this I inserted a loop For with 3 of a second.  I created indicators for the two terminals of the iteration.  When executing the VI, I found the while loop waiting for loop For run N times before the while loop is executed again.  I also found that sometimes the first iteration of the loop For ends at 1 second instead of 3 seconds and the STOP button to complete execution of the While loop does not always work.

    This is the expected behavior. LabVIEW is the language of s DATA stream. If you want the curls to be independent, it can be data forcing addictive so use separate loops.

  • for loop nested within a while loop

    I wrote a data logging VI to get data from a data acquisition, then write on a worksheet. It worked well. What I'm trying to do now and I am having problems is to place that vi within a while loop that will automatically write a new file name after the loop For ends its iterations. In a text based program when the loop finished I would just send it to the while loop for her write the new file name, and then run the loop data collection and spreadsheet iterations of writing.  Here is the general outline of the operations of the program.

    Set the file name and path based on iterations of the loop (eventually this will be the date and time)

    run to the loop for the specified iterations:

    read DAQ

    write data to a .csv spreadsheet

    In specified iterations are more:

    new name of file writley

    Rerun the loop for

    Repeat this until you press stop

    What actually happens is the file name and path are established, the loop runs through its iterations, but wrote that the last set of data and then the program stops.

    any ideas?  Program attached

    Don't know about the termination of the program. I replaced the methods with a random number generator and everything seemed good environment according to the writing of worksheet to add instead of create a new file each time that work.

    p.s., cleaned up the wiring to make it readable - counties of cleanliness.

  • for loop in while loop

    To all,

    I have a question, I have a loop within a while loop. The loop runs and displays the log data. It seems that, until I have stop the while loop that log data display. It almost seems that the for loop runs until the while loop is stop.

    The following accessory is an example of what I have in my code. But the because the loop runs in this example. My code is the same idea, but the loop seems to run when I start my program with execution of climax. Otherwise, it runs once I left the while loop.

    All entries?

    Thank you

    Cosmica

    I tried your VI and there is nothing wrong the way in which it executes. Nothing happens until the second tab is selected and you press the 'off' button, date on which the loop FOR runs until the indicator shows a "9". In subsequent runs, again, it count up to nine, but it is so fast that you never see. For the observer, the indicator remains at nine.

    Of course you would see things a little bit better if you place the small waiting inside various parts of loops. At present, the VI consumes all CPU do nothing but turn empty loops for always while spending from time to time some nanosecods to iterate through the loop FOR. You also destroy your resource VISA with tunnels of default output, so the fence at the end probably will fail. Overall, the code seems too complicated for what you want to do. Do you really need to link a case control tab structure? Seems unnecessary. The for loop should run when the button is pressed, since this implies automatically that Your ' e on the second tab, you don't need to read the tab control. It's redundant!

  • Loops For parallel within a Structure of case - one or more threads?

    I wonder if I put parallel for loops within a structure of business will be to the loops have their own thread, or run in the same thread?

    I think it would be a thread, but then I saw this post when looking on the forums to check.  Alas, I ask directly.

    I created the parallel for loops to improve the performance. (I'm in BT 8.5, if do not have the option of clever parallelization by right-clicking the loop for).   The parallel loops have the same code in each (I know I do the reentrant subVIs).  I wanted to put a case around the loop structure, so that they do not run if there is a mistake in them (I have a master/slave updated structure the where the for loops are slaves) because the code inside the for loops is 1) depends on correct data of the master and 2) by the high-performance computing I want to skip execution of loops if the master has a stop command.  Otherwise, errors are likely to be generated in the slaves because of incorrect data by the captain or the judgment happens quickly, which can confuse the user.

    Let me know if you need more details.  Thank you!

    ~ Kristen

    Each loop will run on its own thread and they will work in parallel. The only downside would be if they call them both the same Subvi and the Subvi is not reentrant. Besides, any shared call which blocks will result in two loops is not able to run completely independently.

  • Creating tables in a nested for loop

    Hi all.

    I was stuck in this problem for quite a while now and I still don't know how to continue. Some outside the entrance would be greatly appreciated!

    I'm doing the following:

    -Take an array of numbers, to check if they are within a certain range (e.g. between 2 and 4)

    -Build two new arrays: one with all the numbers that are inside the beach and the other with the rest.

    An additional condition is that the amount and value of the range conditions will change (for example, it could be between 2 and 4 only / 2, 4 AND 6 and 7 according to the entry)

    To treat this, I created two nested for loops - one that goes on a table that contains conditions of the beach and inside that actually go and check if the values are in the range. I think I did that part successfully, but the next part is confusing to me - how to actually create the tables separated within two loops for?

    My apologies if I did not explain it well. Another method to support this problem is I want to translate following LabVIEW:

    Ranges of table / / [1 5 7 10] exodus-> This means we want to divide numbers based on those who are in (1,2) and (4.5) against those who are not

    Table of values / / [2 3 6 11 3]

    EndOperationDelegate table / / array of values within the range
    Table outValues / / Array of values out of range

    for m = 1:size (ranges)

    for n = 1:size (values)
    If (THE NUMBER IS on the INSIDE of EACH RANGE)
    EndOperationDelegate = [EndOperationDelegate NEWNUMBER]
    on the other
    outValues = [outValues NEWNUMBER]
    end

    end
    end

    Sounds easy enough, but it gets so chaotic with Labview that I don't know what to do. I have attached a reference image - insertion in the array function is not in fact add to the table, it creates a new table. How can I save that for when the nested for the ends of the loop?

    I have seen a few examples with shift registers which lie in a loop and I couldn't successfully that transfers in my block diagram.

    Any help/direction would be greatly appreciated.

    Hello!

    See the following example to understand how you can create a table in the loop For

    In your case, you also can uce conditional terminal to create a table only when then located nearby. It makes the code much cleaner that the structures of the case

    Hope this helps, if not, let me know if I can help you!

    Marcin

  • FOR loop does not update the local Variable

    I am newer to labview, and I can't wrap the head around why not a habit of local variable to update in the code if it updates on the dashboard. Anything im missing?

    Assume that you are talking about the local variable of the 'State of the cell. The terminal updates every 500ms in the small top loop, the local variable indicates simply that the indicator and thus updates also.

    The problem is "dataflow" and you need to familiarize yourself with the concept!

    Once the while loop starts, the local variable is reading and inside the loop begins. Most likely, the local variable is read before it is updated in the small loop, so most likely returns the value of a fade on the first iteration of the while loop. Now the small loop continues to go twice per second for about five seconds. Only after the loop FOR (and everything else inside the while loop) completed, the while loop will go to the next iteration, date on which the local variable is read once more, this time with the last value of the last for loop iteration of the previous iteration of the while loop.

    In summary, the local variable updates very well, it's just that the code does not read the new value around most of the time.

    Your VI is full also potential competition conditions caused by the over-use of the local variable. You need to respect the proper execution order by eliminating local variables.

    So what is the solution? Hard to say without knowing what the VI is supposed to do. Most likely, you will need to remove the inside OF the loop and use it outside while loop for everything.

  • How to end Vi in a For loop

    Hello. I enclose my Vi. I have a question about stopping a loop For I have 2 loops for the case "Test underway". I have a termial conditional that will stop my Vi but only after you have completed all the iterations of the loop For I have need of this Vi to stop immediately, when you press the stop button. I realize that it will take probably still finish an iteration, however, at the present time it waits until all iterations are performed, before coming to rest. I'm doing it with the same front button that stops the while loop. I tried a local variable, but to change a mechanical action and I prefer not to do, if this is possible. There was a lot of posts related to this topic here on the forum but I couldn't find the one suited to my needs. Thank you for your time.

    Your While loop waiting loops to stop, so you can use local variables of your stop button to stop the for loops right now.

    See you soon,.

    Jimmy

  • Have different conditions for loop start and stop

    I do a VI when a circle is moving on an image control and its movement is decided by programming, but also by the user. I have programmed the speed of the circle as a vector which turns (using a rotation matrix) when a certain condition is met. This condition is dependent on the position of the circle and direction as well as other entries. The tricky thing is I want to that when the rotation condition is met (true), the rotation continues until the angle of the vector is equal to the original angle (when the condition became real) + / variable x.

    So my question is how do I program a piece of code that once activated, will run until a stop (depending on the State of vector early in the race) condition is reached. As it should be when the VI is on, I can not put a while loop inside an another while loop. Online help mentions also conditional for loops, but it isn't available in my version of LV (8.2)

    The correct solution is a state machine with a case inside a single while loop structure. Based on the need to use one of the several cases and move on to another matter as necessary using a state variable (for example, an enum) in a registry change. One of the cases should be slowed down and not do much except maybe controls survey.

    There are a lot of models.

    Do not hesitate to contact a simplified example of your code and help you.

  • 3D table organization fomr a 1 d array in a for loop

    Hello-

    I am currently using a program OR opening multiple files (http://zone.ni.com/devzone/cda/epd/p/id/818). As a side note, I noticed that the files are automatically organized by name once records are returned from the Subvi. Will be called BxCy where x is a number and y is a number to two digits (e.g., B2C34) and within each file, I load a 1 d table which I extracted the files, I am loading.

    I want to do is organize the output so it has the structure of

    Page C1

    Line B1 [(table 1 d)]

    Line B2 [(table 1 d)]

    ...

    Line Bn [(table 1 d)]

    Page C2

    Line B1 [(table 1 d)]

    Line B2 [(table 1 d)]

    ...

    Line Bn [(table 1 d)]

    and so on.

    My first question is that I'm not 100% sure that the file names will be organised by name in the lu multi-fichier VI so is there someone who can check it out? Second, even with what I would like to know if there are effective methods to achieve this. Should I just use two tables index to classify based on their number of anc C B? This seems to slow down and I saw on other positions the function array reshape could speed up the process but I'm not sure how to proceed. I don't have access to the structures of inplace (I don't know if I just forgot to install this module, or if it was not included in my subscription LabVIEW).

    The program that I joined is in LabVIEW 2009 SP1 and I'm on a Windows 7 64-bit machine.

    Thank you in advance!

    J

    • You did not include the subVIs. Please do.
    • Never convert a path to a string, unless you do something specific OS. Use 'strip path' work on the name of the file as strings, then convert back to a path using "build path" if necessary.
    • To create a 3D tables 1 d array, you need two stacked FOR loops. Pages in the loop external and rows in the inner loop and outoindex in the output in loop tunnels. You will automatically get a 3D Board.
    • It might be much easier to use the "list of files" with a motif of "B * C *" for example. Is the number of the page always 1 and the numbers of two line numbers (padded with a zero not significant as appropriate)? In this case the sorting will be correct.
  • Cursor for loop

    Hey Experts,.

    Can we consider cursor for loop as an example of cursor name

    as

    CREATE or REPLACE function TotalIncome (name_in IN varchar2) RETURN varchar2 IS total_val number (6);   cursor c1 is SELECT monthly_income FROM Employees WHERE name = name_in; BEGIN total_val: = 0;   FOR employee_rec in c1 LOOP total_val: = total_val + employee_rec.monthly_income;   END LOOP;   RETURN total_val; END; In this example, we have created

    SShubhangi wrote:

    Can we consider cursor for loop as an example of cursor name

    Laughing out loud

    Your code example explicitly sets a CURSOR variable in the PL/SQL block. Implied things happening opens, fetch and closing the cursor. But that the cursor is declared (in the DECLARE section), it's an explicit cursor - like the whole code block now has a way explicit to reference this slider.

    An approach of implicit cursor would be as follows:

    begin
      for c in(select col1, col2 from table1) loop
        .. do something..
      end loop;
    end;
    

    As you can see - there is no declaration of a cursor variable. A reference implementation is created instead and are accessible only within the construction that creates this reference - that is FOR loop in this case. The rest of the BEGIN... END block cannot refer to this cursor.

    Do not forget the advice of other posters however. In PL/SQL cursor loops is often the WRONG approach to the treatment of data - as it deals with processing (using the PL/SQL) line and not much treatment faster and scalable set of data using SQL only.

  • Cursor for loop in PlSql

    while I was studying on cursor for loop I found this statement in the web

    "A cursor FOR loop implicitly declares its index of the loop as the % ROWTYPE record."

    for example an emp table contain more columns empno, ename, sal, hiredate deptno

    and take a cursor for loop until

    for rec in select empno, sal from emp loop

    If the cursor loop for said index of the loop as a % rowtype our cursor statement must include all columns and follow the data type compatabulity.

    Here our cursor statement includes only a few columns, if we use % rowtype to select all columns but here we do not have it.

    Please can someone explain what is happening in the cursor for loop?

    Type % line is not for the table. its for the cursor.

    its almost like cursor % rowtype

    Select ename, sal from emp will be rowtype of ename and sal... not all the columns EMP

  • declareing cursor for loop inside another cursor for loop

    Hi friends,

    Is it possible declareing cursor loop within another cursor for loop for.

    Please guide for example?

    You can even declare cursor within the cursor loop

    declare
    cursor c1 is select deptno from the Department;
    BEGIN
    for cr1 in c1
    loop
    declare
    cursor c2 is select ename from emp where deptno = cr1.deptno;
    Start
    for cr2 in c2
    loop
    dbms_output.put_line (CR1. DEPTNO | ' ' || CR2.ename);
    end loop;
    end;
    end loop;
    end;

  • slider with a for loop

    Hi all

    I have a simple slider in my pl/sql procedure. I use the method for the slider of the loop and retrieve the values below.


    DECLARE

    VAR_A VARCHAR2 (100);

    CURSOR C1 IS
    SELECT DEPT_NAME, DEPT_NO OF THE DEPARTMENT;
    BEGIN

    FOR I IN C1
    LOOP
    VAR_A: = I.DEPT_NAME;
    END LOOP;

    -etc etc.
    -etc etc.

    EXCEPTION
    WHILE OTHERS THEN
    DBMS_OUTPUT. Put_line ('hello');

    END

    This workfine but if the DEPT table does not all records in it, it goes directly to the management of exceptions, and if there are all the other instructions after the FOR LOOP, they will not be executed. I know there is a method to use the cursor (instruction FETCH) more, but I want to know what is wrong by using the FOR LOOP.

    The strange thing about this example is, even if I catch the exception, the program stops and if the DEPT table has no recording errors.

    Any suggestions or tips are greatly appreciated.

    the program stops and if the DEPT table has no recording errors.

    This seems a little suspicious. Probably another error product which is now hidden simply because of your manager WHEN of OTHER of exceptions, that didn't come out the real error message.

    I recommend getting rid of the exception handler together and after the release of the thrown exception.

  • Cursor object and cursor for loop back

    I am beginner in Oracle and the serious database of programming in general. Right now I'm studying the sliders. I more or less understand how works when the cursor returns a record, but I can't understand why this does not work when the cursor return object and I use "cursor for loop.

    Here's the test code:

    CREATE or REPLACE TYPE typ_Test () AS OBJECT
    text VARCHAR2 (50)
    );

    CREATE TABLE t_Test to typ_Test;

    INSERT INTO t_Test VALUES (typ_Test('111'));
    INSERT INTO t_Test VALUES (typ_Test('222'));

    -work, simple loop
    DECLARE
    CURSOR cur IS SELECT VALUE (o) FROM t_Test o;
    typ_Test obj;
    BEGIN
    Heart OPEN;
    LOOP
    Fetch cur INTO obj;
    OUTPUT WHEN heart % NOTFOUND;
    dbms_output.put_line (obj. (Text);
    END LOOP;
    CLOSE cur;
    END;



    -doesn't work, cursor for loop
    DECLARE
    CURSOR cur IS SELECT VALUE (o) FROM t_Test o;
    BEGIN
    FOR news of obj IN LOOP
    dbms_output.put_line (obj. (Text);
    END LOOP;
    END;



    Error report:
    ORA-06550: line 5, column 30:
    PLS-00302: 'TEXT' element must be declared.
    ORA-06550: line 5, column 5:
    PL/SQL: Statement ignored
    06550 00000 - "line %s, column % s:\n%s".
    * Cause: Usually a PL/SQL compilation error.


    EDIT:
    In fact I found no examples on the net of its use "cursor for loop" with cursor that returns the object. Only when the record is returned...

    Published by: user10393567 on February 10, 2009 07:38

    user10393567 wrote:
    Now, in the 'loop' example for what looks "obj" is a folder, not an object, and 'x' is attribute of this recording... But the cursor must return an object, not a record... What Miss me?

    In the FOR loop "obj" is a pointer to the cursor/query, not a subject in its own right. It gives you just a reference in the query.

    So with that you are referring to the query, but then you need to refer to the column in the query that you are interested, so why there need a name (in my case I called it 'x'). 'x' is the object, and then you refer to the attribute of this object "text".

    In the first request that you simply select the value directly object in a variable, so no matter what it's called in the query values are returned by the position that is the first column in the query goes into the first variable in the INTO clause. Once you have that then the variable itself contains the object, and you can just refer to the attribute within that.

    Hope that makes sense.

Maybe you are looking for

  • Bad certificate - what I do

    I get secure it connection failed for www.google.com. Your certificate contains the same serial number for another certificate issued by the certification authority. Please get a new certificate containing a unique serial number. (Error code: sec_err

  • How to change the screen lock and mute on the parameters?

    Hello, I was wondering how to activate the rotation of the lock and mute my IPhone4s, I looked in the settings of a lot of time for it and I can't seem to find it. It would be so great if someone could help me figure out how. Either way, I have the v

  • speech recognition - "this command is not available now"...

    I have windows 7 with office 2010 and when I try to say commands, such as select Word or correct the word or ordering another new paragraph I receive a message of this command is not available now... when it will be available? also, when dictating a

  • BB10 implements a kind of techniques of coalescence of time?

    Hello With iOS 7, Apple has made some improvements on the use of resources. Here are some technical info on it. Also no technique here. I was wondering if BB10 - or operating system QNX Neutrino - implements something similar. If Yes, can someone exp

  • Error code 0 x 80270200 when you create a new folder.

    Original title: error code 0 x 80270200 I am trying to create a new folder in Windows 8, but appears this error code: 0 x 80270200 unknown error.  I can't find information on this error code. Can anyone help?  Thank you!