State Diagram inside For Loop

I created a fairly involved for-loop with a flat sequence inside of it.  The sequence had about four events that occured, and since it was kind of ugly, I thought I'd try the State Diagram Toolkit to replace the majority of the code.  When I selected state diagram from the pallete, I was outside my for-loop.  I drew up the various states/transitions, then realized that all this code needed to be inside the for-loop, but LV won't let me place state diagram-generated code inside the for-loop.  I select everything related to the state diagram, but when I drag into the for-loop, only the comments come inside.  I even tried generating a new for-loop and placing the state code inside.  No luck. Any thoughts?

"Any thoughts?"
Yes but not any that will help.
1) Just modify your SD so that the exit loops back to the start while there are still things to do. Forget the outer For loop.
2) THe observations you reported are correct. When I first discovered these limitiations I said "That sucks!". Since then I have learned a bit and have grown to love the SDE.
The SDE is JUST (note: "just" is a four letter word around here ) a LV application that ofers a very limited GUI consisting of a picture control that then scripts (see LAVA Scripting Forum for info on scripting) your SD for you. SCripting LV code is no easy task. My experiments with scripting has shown that I have to keep a database of the contents of the LV diagram my code is developing to keep track of what is where. Well it turns out that the structure of a LV diagram is a lot like the structure of a FP in that you start with a "root" object either the FP or the BD. THe BD then has structures on it, like seq's loops etc with unlited nesting possible.
Now the SD created by the SDE is really just a fancy while loop with an case structure and code to support the driving enum. In order for you to be able to edit the SD the SDE needs to know what is htere already so it can show the diagram. It "KNOWS" by looking at its internal DB (I believe is stored inside of VI along with the enum.ctl) of the SD. To keep the DB updated, the SDE must be used to manipulate the SD.
Stop rambling and guessing and get to the point!
Moving the SD is just not supported by the SDE so it can not be done. To do so would require the SDE be able to "look" at the diagram, and repeat all of its work in the new location in the diagram.
BTW: Thank you for trying out and asking about the SDE. the more talking we do on this subject, the sooner the SDE will be updated.
My SDE wishlist (partial)
Add comments to diagram from SDE screen.
Add data structures to SD (shift registers) from SDE screen.
Add "un-do".
Select multiple objects on SDE screen and move or allign.
Select multiple objects on SDE screen and do "create sub-State-Diagram".
Allow watching more than one SDE in execution highlighting at the same time.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • How do we use if statement in labview?moreover can i use if statement inside for loop?

    how do we use if statement in labview?moreover can i use if statement inside for loop?

    The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
    Attachments:
    For_Loop_with_Case.jpg ‏21 KB

  • Best practice: Using break statement inside for loop

    Hi All,
    Using break statment inside FOR loop is a best practice or not?
    I have given some sample code:
    1. With break statement
    2. With some boolean variable that decide whether to come out of the loop or not.
    for(int i = 0; i < 10; i++){
    if(i == 5){
    break;
    boolean breakForLoop = false;
    for(int i = 0; i < 10 && !breakForLoop; i++){
    if(i == 5){
    breakForLoop = true;
    The example may be a stupid one. But i want to know which one is good?
    Thanks and Regards,
    Ashok kumar B.

    Actually, it's bad practice to use break anywhere other than in conjunction with a switch statement.Presumably, if you favour:
    boolean test = true;
    while (test)
      test = foo && bar;
      if (test)
    }overfor (;;)
      if (! ( foo && bar) ) break;
    }then you also favour
    boolean test = foo && bar;
    if (test)
    }overif (foo && bar)
    }Or can you justify your statement with any example which doesn't cause more complexity, more variables in scope, and multiple assignments and tests?

  • Statement error in for loop noobq

    Hi
    Could anyoe tell me why this wont work? Its supposed to count upp to tal in the first one and then count down from tal in the second and its the second one that dont work. I get a statement error for the text i put in between stars (supposed to be bold but i dont know..)
    thanks
    class r?knaa {
        public static void main(String[] args) {
            new r?knaa().run();
        void run() {
         int tal = Keyboard.nextInt ("Ange ett tal ? s? ska vi r?kna...(^_^): ");
         for (int upp = 1; upp <= tal; upp = upp + 1) {
             System.out.print ( upp+ " " );
         System.out.println (" ");
         System.out.println (" ");
         for (*tal*; tal > 0; tal = tal -1 ){
             System.out.print ( tal+ " " );
    }Edited by: gibitlib on Feb 19, 2010 3:02 PM

    jverd wrote:
    sharkura wrote:
    I assumed that it would decrement after the block of statements associated with the while loop, as is true with the for loop.Not sure what you mean by "as is true with the for loop", but I'm catching a hint of a very common misconception about the post-inc/dec operators.
    A LOT of people think that post-inc/dec means "last step in the statement" or "after everything else has been done" or something like that. That kind of thiiking is just black magic hocus pocus and serves no purposeI don't think I thiik like that, Jeff. I've never used a post-inc operator in a while loop. Certainly, if I felt a need to do so, I would test it, and try to understand why it works the way it does. Empirically, I know that given the following for loop:
    for ( int i = 0; i < limit; i++ )
      ... some statements
    }the incrementation of i occurs after the statements in the block execute. It may be specific to the for loop that the third statement in the for loop executes after the block of statements, in which case
    for ( int i = 0; i < limit; ++i )
      ... some statements
    }would work the same, and you can bet I will test that.
    I did make an assumption last night, and did not test it. That is not typical of me. I do resent somewhat the accusation of black magic hocus pocus. My last statement in that post was:
    sharkura wrote:
    I'll have to play with this some.Implicit in that remark was my intent to read more about pre/post decrementation and experiment until I more fully understood it. You have pointed out my lack of complete understanding, and, odd as it may seem, I appreciate that. I do log into these forums, partly, to improve my understanding of java.
    {?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Stacked sequence inside for loop question

    Hi everyone,
    I am new to LabVIEW and I just want to make a for loop with a stack sequence inside. I want it so that when the for loop executes for the n-th time, the stacked sequence is at the n-th frame (because each frame contains different tasks to be carried out). Is this possible? or is there an alternative equivalent method? Please help me out! Thanks!!

    Thank you Norbert for the words of advice.
    Try to avoid Stacked Sequence Structures at all cost.  They are a nightmare to deal with when maintaining the code and they do not offer simple scalability, especially if you need to deal with parallelism.
    As Norbert suggested, State Machines is the way to go.  Try to avoid naming covention such as 1...2...3...4...5.......9999.  Give the name of each case based on what that case does.  Create a TypeDef Control for the state selector (you'll thank me after having changed it for the 5th time   ).
    There are probably 100's of examples in this forum.
    RayR

  • Is it possible to put property node inside for loop?

    I have created three separate property nodes (plot color) for my 3 XY graphs.
    Is it possible to have one property node, say plot_color_i and put this inside the for loop where i runs from 1 to N,
    where plot_color_1 would update XY Graph 1, plot_color_2 would update XY Graph 2, etc.?
    See the attached VI.
    Solved!
    Go to Solution.
    Attachments:
    XY Plot Example.vi ‏18 KB

    Yes.  Create an array of references of the XY graphs and have that auto-index into the property node in the For Loop
    Attachments:
    XYPlotExampleMOD.vi ‏18 KB

  • Commit inside For Loop

    Hi,
    I have a query which is updating millions of records and is inside a for loop . I have issued commit inside that for loop only . Which one will be better . Should I issue the commit inside the for loop or outside it .
    Thanks in Advance,
    Rahul Guha Ray

    No it is not technically true but ajallen has a valid point. Under traditional rollback segment management reading and updating the same table where large quantities of data were changed with frequent committing was probably the number one cause of snapshot too old errors. However, there are many factors that play into this so even under traditional rollback segment management how likely you are to get an error depends: total size of transaction, total run time, concurrent access, and amount on rollback space available.
    With undo segment space management it largely depends on the total transaction size and runtime verse how much undo you have and your retention policy.
    At some point re-opening the query may indeed be a good idea. One approach is to code to re-open the query only on getting the 1555 error. Some updates however cannot be resumed easily as the update does not mark the row in such a way as the query or where clause conditions can exclude it. In cases like this saving restart information with each commit is necessary.
    A lot of different factors have to go into the decision of how often to commit.
    -- Mark D Powell --

  • Select statement in a for loop

    Hi all,
    Can a select stmt be used in the body of the for loop/ nested for loop ?
    I tries using (even if its very simple for loop) it gives the following error
    PL/SQL: ORA-00933: SQL command not properly ended...
    code is
    DECLARE
    CURSOR C1 is select 'Monday'  from dual
    union all
    select 'Tuesday' from dual
    union all
    select 'Wednesday' from dual
    union all
    select 'Thursday' from dual
    union all
    select 'Friday' from dual
    union all
    select 'Saturday' from dual
    union all
    select 'Sunday' from dual;
            type rec_info is record
            name varchar2(20),
            FNAME varchar2(20),
            LNAME varchar2(20)
            type ty_info is table of rec_info;
            info ty_info;
            type rec_abc is record
            day varchar2(3000)
            type ty_abc is table of rec_abc;
            abc ty_abc;
            Cursor C2 is
            select t.name, u.first_name, u.last_name
            from territories t, users u, territories_users tu
            where t.ID = tu.TERRITORY_ID
            and tu.USER_ID = u.ID ;
    BEGIN
    OPEN C1;
    Loop
    FETCH C1 into abc;
    EXIT when C1%notfound;
    DBMS_OUTPUT.PUT_LINE(abc);
    END LOOP;
    CLOSE C1;
    OPEN C2;
    FETCH C2 BULK COLLECT into info;
    CLOSE C2;
           for i in info.first .. info.last
           LOOP
                       for j in abc.first .. abc.last
                       LOOP
                              select --info(i).name, info(i).FNAME, info(i),LNAME,'AM' "AM/PM",
                            to_char(c.name)||' '||ct.PRIMARY_ADDRESS_CITY||','||ct.PRIMARY_ADDRESS_STATE||','||ct.PRIMARY_ADDRESS_COUNTRY
                           from
                            territories t, territories_users tu,
                            users u, calls_users cu, calls c, 
                            calls_contacts cc, contacts ct    
                            where
                            tu.TERRITORY_ID = t.id
                            and t.name = info(i).name
                            and u.first_name = info(i).FNAME
                            and u.last_name = info(i).LNAME
                          and (c.date_start between trim(next_day(sysdate,abc(j).day)) and trim(next_day(sysdate,abc(j).day)))
                            and tu.USER_ID = u.id
                            and cu.USER_ID = u.id
                            and cu.CALL_ID = c.id
                            and to_char(c.time_start,'hh24') < '12'
                            and cc.CALL_ID = c.ID
                            and cc.CONTACT_ID = ct.id
                            and rownum < 2
                     END LOOP;
         END LOOP;
    END;

    "Can a select stmt be used in the body of the for loop/ nested for loop "
    Yes.... but with an INTO part.....
    select c1 , c2 , c3 into var1 , var2 , var3 from table1
    Sim

  • Initializing variables inside for-loop?

    Dear all,
    It's been a while since I last programmed in Java, and my skills seem to be a bit rusty.
    I have a question for you here: suppose I need to initialize n (let's say 10) different integers, I suppose I couldn't use something like this:
    for(int i = 0; i < 10; i++){
      int <&iquest;VALUE?> = i;
    }Is there a way to dynamically initialize <VALUE>, for instance something like ("integer" + i)? (integer0=0, integer1=1, integer2=2, etc.)
    Thank you,
    Maarten

    You need to declare the arrays in a context outside of the for loop, the for loop context will end and so will all of your locally declared variables. Now there is a way around that:
    Make an ArrayList, in a "Global context" to your loop, and initialize your variables in the for loop, then add them to the ArrayList, once you are out of the loop, then the ArrayList will hold your references to your variables and keep them from being disposed. When you are done with them, then just remove them from the ArrayList.
    ArrayList<myNodes> al = new ArrayList<myNodes>(); //in a "global context"
    for(int i=0; i<iSomeNumber; i++){
      MyNode n = new myNode();
      //do what ever
      al.add(n);
    }If you need key values to look up your nodes by, then you a Map of some type instead of an ArrayList.

  • For Loop Inside A For Loop

    Is it possible to execute all the iterations of the inside for loop for each iteration of the outside for loop? I have attached a screenshot of my program if it helps. If it is possible could you tell me how to do it plz?
    Solved!
    Go to Solution.
    Attachments:
    Capture.PNG ‏53 KB

    One thought I have is that I think you want those feedback nodes reinitializing for each iteration of the outter loop.  Personally, I would change them to be shift registers (it would clean up your diagram a little bit).
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is this another form of a cursor for loop?

    Hi,
    I'm working, in Oracle 10gR2 in Windows XP, on a stored procedure that was given to me mostly completed and I'm trying to decypher the syntax of the cursor.
    CREATE OR REPLACE PROCEDURE p_proc1(p_from_date IN DATE
                                                        ,p_to_date   IN DATE
                                                        ,p_result_cur   IN OUT dbo.pkg_q.ref_cursor) IS
    BEGIN
        OPEN ,p_result_cur FOR WITH wr AS(
            SELECT wr.F1
                  ,wr.F2
                  ,wr.F3
                  ,wr.F4
              FROM work_report wr
             WHERE 1 = etc.               )
                SELECT AF1
                           ,AF2
                           ,AF3
                FROM history h
                WHERE something = somethingelse;Is the 'OPEN ,p_result_cur FOR WITH wr AS(' code just a complex cursor for loop? and how does the 'WITH' fit into it?
    Thank you!

    Hi,
    Paul Davis wrote:
    Hi,
    I'm working, in Oracle 10gR2 in Windows XP, on a stored procedure that was given to me mostly completed and I'm trying to decypher the syntax of the cursor.
    CREATE OR REPLACE PROCEDURE p_proc1(p_from_date IN DATE
    ,p_to_date   IN DATE
    ,p_result_cur   IN OUT dbo.pkg_q.ref_cursor) IS
    BEGIN
    OPEN ,p_result_cur FOR WITH wr AS(
    SELECT wr.F1
    ,wr.F2
    ,wr.F3
    ,wr.F4
    FROM work_report wr
    WHERE 1 = etc.               )
    SELECT AF1
    ,AF2
    ,AF3
    FROM history h
    WHERE something = somethingelse;Is the 'OPEN ,p_result_cur FOR WITH wr AS(' code just a complex cursor for loop? and how does the 'WITH' fit into it?I think the comma before p_ref_result_cur is a typo; there should only be space there:
    OPEN p_result_cur FOR WITH wr AS ...There's no loop in the fragment you posted: the OPEN statement does just that; it opens the cursor so later FETCH statements (perhaps inside a loop) can get data.
    "WITH sub_query AS ( .... ) SELECT ..." is one way of writing a query.
    For details, see the SQL Language manual:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9758

  • Just wanna do a for loop

    Just wanna do a for loop by using a method. The error I'm getting is
    java:6: missing return statement
    public int for1(){             
    ^
    1 error
    import java.util.*;
    public class forloop{
         public int for1(){          
              for(int i = 1; i <= 100; i++){               
                   System.out.println(i);
                   return i;          
         public static void main(String args[]){
              forloop a = new forloop();
              a.for1();

    Oh i see the problem was i didn't declare i in the
    class before i used it in the method definition. I
    thought the way i declared it in the for loop would
    work, oh well.no-no. the problem was, that you returned something only inside for loop, but compiler was not sure that thing from the for loop would be returned, so it was bitching about that...
    if you had written your for statement like that:
    for (int i=0; i < -1; i++) {
    return i;
    then body of return statement would not had been executede, therefore nothing would have got returned, and that's the case about what this compiletime error was telling you...

  • Read data from text file one by one using for loop

    Dear Forum
    I want to read data of single colum of text file inside the for loop one by one(for each iteration value must be replaced by another value of text file).This value is used by a formula inside for loop. also after completion of iterations the values must be plotted on xy graph. How to do it.? please help me.
    profravi

    It's not very efficient to read a file line by line. Much simpler to read it all at once and then auto-index the results inside a for loop. The image below shows a generic solution to your problem. This assumes that the data in the file is in a single column.
    I would also recomend checking ou the learning LabVIEW resources here.
    I would aslos suggest that since this type of question is not specific to either NI-Elvis or the LabVIEW SE, you should post similar questions to the LabVIEW board. If you have problems, attaching a sample of the text file would help.
    Message Edited by Dennis Knutson on 10-18-2007 09:11 AM
    Attachments:
    XY Graph From File.PNG ‏4 KB

  • How to output data outtside a for loop every 10 iterations​?

    Hi friends,
    does any body help me to sort out this problem?
    please check the attchement for my vi.
    all i want is output data from inside for loop to outside for loop every 10 iterations. please do not use local variable.
    Many thanks
    dan
    Attachments:
    output.vi ‏16 KB

    Hi Dan,
    I am not sure what you want to do every 10 iterations with the value outside, but If you want to update your graph every 10 iterations use the following way:
    If you want to handle the specific value every x iterations outside the loop you could either use queues or notifieres.
    BR,
    ThSa
    Message Edited by ThSa on 08-23-2006 09:05 PM
    http://www.newgistics.com
    Attachments:
    1.png ‏6 KB

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Tax Report for Canada

    Hi everyone!! Does anyone knows the tax report that should be used for Canada? We have advised the business to use the standard S_ALR_87012394 (Record of Use and Sales Tax - USA) as it provides de info by customer/vendor, tax code and jurisdiction co

  • How to get Acrobat Pro 7 to convert JPG's

    Hi Im currently using Acrobat Pro 7 ver 7.0.0 on a Windows XP Pro SP3 machine. Lately Acrobat has been struggling to convert jpeg files into PDF resulting in blank pages with nothing on them. Usually, i would edit the jpeg in Elements 9 and then save

  • Exit in Idoc processing

    Hi gurus, I'm new on Idocs and maybe it's a silly question. My requirement is to send a custom Idoc with the result status from an inbound standard Idoc COND_A04. It's like some kind of acknowledge. Because of a requirement, I'm unable to use custom

  • General Error when Doing Export

    I'm getting a "General Error" when exporting a sequence, both as a reference QuickTime and as a self-contained QuickTime file. The process goes along until a certain percentage (73%), and then it bails, and gives this not-very-specific "General Error

  • Cvirte.dll and Windows Vista

    Hi everyone, I used to have .DLL compled in LabView 7.1 that worked just fine in Windows XP. Now, I have rebuild it for Windows Vista. I have installed LabView RuntimeEngine 8.51. It's not working. Can you point out why?!  However I was wondering wha