Exit a while loop inside an event case

Hi All, I have a multi-page program. One of it is used to read some analog signal via a USB block continuously.
What I want is when clicking this page, this while loop is activated. Then we can monitor the data. When we click other pages or "Stop" button, this while loop will be terminated. And we can use the other pages to do something else.
Right now I got difficuties in stop the while loop. I do not want to stop the running of the whole program, just want to jump out of this while loop then do other operation.
Could anyone give me some advise how to do it? Thank you very much! 

Hi RavensFan, thank you for your reply.Actually this is not my real code  because the original one is very very compliacted.
In real code, the tab control you see in inside the bigger while loop, that loop makes the whole program work.
And as what I pointed, the purpose is when I click this tab (if we do not want it to trigger, we can place another "START" button to trigger), an internal while loop inside begins to run. This while loop keeps showing the real time analog signal.
And if I do not want to use this "real time monitoring" function, I want to click somewhere (or doing anything else that can work) to jump out of this internal while loop and keep on using some other functions of the program.
Could you advise about that? Thank you very much! 

Similar Messages

  • Event controll: How to stop a running while loop inside a event structure

    Hello,
    I have some problems with controlling a while loop inside a event structure (see attached VI).
    I habe 3 buttons ("Start Measurement, Stop Measurement, Quit Program"). When a measurement is running, it should be possible to stop the measurement by clicking on "Stop Measurement", but this does not work.
    Has anyone an idea?
    Thanks a lot and best regards,
    Michael
    Message Edited by MichaGue_01 on 04-23-2010 04:37 AM
    Solved!
    Go to Solution.
    Attachments:
    Event_Controll.vi ‏27 KB

    Hello,
    Try not to use while loops inside a Event structure.
    My approach is using two While loops (one will have only the Event structure).
    I had to use to Flag buttons that make it a bit more complicated but i am sure somebody will come up with a better idea, or you might want to have a think about it yourself.
    Have a look on the modified version on the attachment.
    Once you are happy how it works then you can Hide the 2 flag buttons from the Front Pannel by going to Block diagram right-click the indicators and choose option "Hide Indicators/Controls"
    I did it in LV 8.6 so i hope you can open it on your PC if not i can downgrade it.
    If you have any problem let us know.
    Regards
    Dimitrios
    Test Systems Computing Engineer
    Cummins Turbo-Technologies
    Attachments:
    Event_Controll[1]_modified.vi ‏18 KB

  • While loop inside a event structure

    Dear
    I have no much concepts on event structure.
    Let's assume there is a dialog box with Okay and Cancel button.
    I put the event structure for Okay and Cancel button.
    In Okay event, there is a while loop for detecting some data continuously.
    In this case, I want to use Cancel button to stop the while loop during the detection.
    How can I do to receive signal from the Cancel button?
    Thank you in advance.

    I'm not sure that the event structure should be used to handle that situation : while the OK event is executing, either the Front panel is locked and new occuring event will be stored until the OK event is completed (so the Cancel button action will not be detected !) or the Front panel is unlocked (see below *) and the Cancel button action will stop the loop, but the Cancel button event case will not be executed, since the event has already been processed in the OK case !
    You should probably use a single button to run/stop the loop, as shown in the attachment
    * While editing the event case, unmark the "Lock front panel for this event complete" at the bottom. But of course, the code in the cancel case will not run, since the event occuredMessage Edité par chilly charly le 03-31-2007 05:27 PM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Event button.vi ‏11 KB

  • How do i exit a while loop using event handler

    Hello,
    I have an event handler structure within which i run a while loop for a particular event. I would like to interrupt the execution of this while loop as soon as another event occurs, even if the while loop has not finished execution. I have tried so many ways, the best i could get is exiting one itteration after the new event occurs which is no good for me.
    Any suggestions???
    Thanks
    Me

    Instead of having a task while loop in an event case, put your task while loop in parallel with the loop surrounding the event structure. When the event which should start the task occurs, you can signal the start of the task while loop. You could use local variables of references to start/stop the loop when an event occurs. You could also use notifiers instead of variables to pass signals to start/stop the while loop. In general you should have a while loop for the event structure, and a parallel while loop to do the tasks. The parallel loop is controlled by variables or notifiers which are set in the event cases.
    - tbob
    Inventor of the WORM Global

  • How to EXIT the while loop in Event response section?

    I'm writing a program to grab image using a NI card. The application uses the Event structure. When the GRAB button was pressed, it snaps image continually by putting the SNAP function in a while loop. Is there some way to exit the while loop?(Note :The while loop was put in the GRAB IMAGE event response section.)

    edit this event-case AND uncheck "lock front panel until the event case for this event completes".
    BTW, your thanks should go to Ankita, <a href='http://forums.ni.com/ni/board/message?board.id=170&message.id=151282'>here</a>
    cheers! 
    Message Edited by Dynamik on 11-13-2005 01:26 AM
    Message Edited by Dynamik on 11-13-2005 01:38 AM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    untitled.GIF ‏20 KB

  • How to exit from the DO-while loop in the event structure

    Hi all
    I am just a beginner for Labview
    I want to build a loop in the event structure, but when I enter in the loop, it seems the system is dead, and I can't exit the loop.
    here I attached a simple sample.
     In the sample.  when I press the start_calculation button , the calculation start, but the system is dead, and I can't exit calculation loop.
     actually, i just want switch the different operation by changing the event action.
    anybody has a good idea about it??
    thanks so lot
    Attachments:
    event_problem.vi ‏17 KB

    Your problem is that you are trapped inside an event case. It is not a good idea to run extended code inside event cases, else the event structure cannot service other events.
    Why don't you use the outer loop for everything? Now things don't step on each others toes. What good is an event structure if it cannot react at all times???
    Message Edited by altenbach on 07-25-2008 12:26 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    event_problemMOD.vi ‏17 KB

  • While loop inside a timed loop

    Hi everybody!
       I'm using:
           - LV 7.1 + RealTime;
           - compactFieldpoint;
       I've noticed a strange behaviour, when I put a while loop inside a timed loop.  Let's fix timed loop with these settings:
           - 1 KHz clock
           - 1 ms period (yes, I know it's short....)
           - offset 0 ms
           - Phase 0
           - Discard missed period (ON) and MAintain original Phase (ON);
           - Timeout: -1.
       If inside this loo, I put a traditional while loop, waiting (say) for an event to occur, and if this event does not arrive, my cFP-2020 hangs! I mean, it becomes unreachable for the debugger, and, more, if I run a ping to it's address, after some cycles it becomes unreachable also from ping!
       Clearly, this code statement lock the fieldPoint, because if I remove the inner while loop all works.
      I know that with 1 ms period, timed loop always finishes late, but I set to discard missed period and timeout to -1. 
       It seems to me that sometimes Timed Loop add heavi overhead to programs, I'm turning to all while loop based tasks, even if my application has to be real-time!
       Advices welcomed! Have a nice day!
    graziano
    Solved!
    Go to Solution.

    I think the issue here is that putting your while loop inside a Timed Loop increases the priority for that task. Timed Loops can have dynamic priorities set over eachother, but they all run between Above Normal and Time Critical priority. My guess is that the debugger and built-in TCP functions run at Above Normal priority or less. This means your cFP isn't hanging, it's doing what it thinks is best. It's trying to finish this task before handling any lower-priority tasks.
    The suggestion to put a Wait function in your loop is an OK one. Keep in mind that you can actually set your wait time to zero instead of one and get the same positive benefit of handling other tasks. I would also suggest that you might look into waiting for this event in a lower priority (non-Timed) loop, and then transmit the appropriate data to your Timed Loop using an RT-FIFO or something. That might give you better handling. Just a thought....
    Jarrod S.
    National Instruments

  • Can't we use while loop inside a fn

    i am using a while loop inside a fn
    it is showing error
    the code is
    while (a=1) loop
    some condition
    end loop;
    the error is
    PLS-00103: Encountered the symbol "WHILE" when expecting one of
    the following:
    * & = - + < / > at in is mod not rem then <an exponent (**)>
    <> or != or ~= >= <= <> and or like between overlaps || year
    DAY_
    The symbol "*" was substituted for "WHILE" to continue.
    PLS-00103: Encountered the symbol "LOOP" when expecting one of
    the following:
    . ( * % & = - + < / > at in is mod not rem then
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between ||
    what is the error

    It looks like the OP misskeyed the assignment operator and got compilations errors, and from that assumed that you can't use WHILE loops in functions on a Tuesday.
    Message was edited by:
    William Robertson
    I was thinking of his is it possible to increment a value in a function, though I suspect the problem is similar.

  • How do I exit a while loop which has a 'read from spreadshee​t' pop up in it?

    I have a while loop which calls 'read from spreadsheet'. My problem is that after entering a filename the loop repeats too quickly for me to hit the end loop button. How do I exit the loop without adding a delay after the read thereby slowing the loop when I don't want to exit. If I select cancel I get 'error 43'. Is there a way to to use an error handler to prevent this from popping up and use it to end the loop?

    It's the error handler inside Read From Spreadsheet that creates the message. Specifically, one of the VIs called is Read Lines From File. The last VI in there is General Error Handler. You can delete it and save it with a different name. You should also modify it to return the error cluster. You'll also want to modify Read From Spreadsheet to return the error cluster so that you can trap the error in your VI. When cancel is selected, error code 43 is generated. Stop the loop when you see 43.

  • Ending a while loop inside a while loop

    How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way?
    Thanks.

    Hi Jasonalan,
    I am not sure what you are trying to implement, but it is true that the loops are not terminating because of data dependency. The stop button in the outer loop will not be read until the inner loop terminates.
    If you wish to terminate the two nested loops using a single stop button, you should read the stop button inside the inner loop and wire it to the conditional terminals in both the inner and outer loop. Again, there is no point in doing this unless you have some other logic along with the stop button to stop the loops. If only the stop button is being used to stop both the inner and outer loops, the outer loop will only execute once. In that case, you can just use a sequence structure followed by a single while loop.

  • Simple example - Break FOR loop inside an event structure based on Front panel event change.

    I am running a for loop inside a state machine architecture that contains a FOR loop. How can I break this For loop based on Event change in front panel ??
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.vi ‏19 KB
    Case inside Event.ctl ‏6 KB
    Case inside Event 2.ctl ‏6 KB

    Okay. Accpeting that the design is not favorable and not advantageous when my program expands. I have begin to follow producer/consumer programming architecture.
    Please find the attached program which is a simple producer consumer with event structure. I wonder how could I stop looping around the producer and consumer loops over and over again. I am pretty sure that this ENQUEUE ELEMENT loops back to the consumer loop and starts from begining.
    I hope my first program in PC architecture with State machine and Event structure is correct. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.3-ProducerConsumer Event.vi ‏25 KB
    Case inside Event.ctl ‏6 KB

  • Stopping a while loop inside a while loop

    Hello,
    I have a while loop which is inside a while loop which houses my enetire application, When stopping the inner while loop portions of my outer loop stop working, How do I setup the inner while stop that it will not interfeer with the outer while loop?
    Thanks,
    Gil,

    It sounds like he is using a simple archetecture.  But switching to a different archetecture may not be necessary.  Simply because it doesn't work, doesn't mean scrap the whole thing and start over.  He's got a bug and needs to fix it.  Is it the best archetecture to use, absolutely not, but simple or general archetectures can be effective based on the application.
    Post your VI so we can take a look and give you some pointers and suggestions for improvement.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • 'While Loop' inside a 'Repeater' executes only once

    Hi,
    I am using a 'While Loop' action inside a 'Repeater'. The while loop executes only for Repeater.CurrentItem = 1 and not for the subsequent items. Any clue?
    Regards,
    V M.

    And the 'While_Loop.Break' = "false". Thaks for the tip.
    Regards,
    V M.

  • How to exit from while loop

    Hi
        I want to exit from loop if error is encountered.
    THanks

    Hi Sonu,
    This is not a question related to the SDK. This is more of a coding question you should probably try something like StackOverflow or MSDN forums for that next time.
    Regarding your question it depends on the language you are using. If you are using c# you can use the keyword "break;" inside an if that checks for the error. In VB you can use "Exit For" or "Exit While".
    Best regards,
    Pedro Magueija

  • My First while loop inside PL/SQL block not working , please help

    Hi ,
    I am new to PL/sql and struck at PL SQL blocks , please help to solve this .
    declare
    v_A number constant :=10 ;
    j number constant := 3 ;
    BEGIN
    WHILE j < v_A
    LOOP
    DBMS_OUTPUT.PUT_LINE('Hai');
    END LOOP;
    END;
    please help as how to resolve this .
    Thanks in advance .

    btw it's a useful habit to use indentation to highlight the block structure. Also it's worth deciding what your convention will be for keywords (I use uppercase, lowercase is also fine as far as I'm concerned but I've set up my editor to uppercase them) and variables, database object names etc (I use lowercase), e.g:
    DECLARE
       v_a CONSTANT PLS_INTEGER := 10;
       j   CONSTANT PLS_INTEGER := 3;
       i PLS_INTEGER := j;
    BEGIN
       WHILE i <= v_a LOOP
          DBMS_OUTPUT.PUT_LINE(i);
          i := i +1;
       END LOOP;
    END;or perhapsdeclare
       v_a constant pls_integer := 10;
       j   constant pls_integer := 3;
       i pls_integer := j;
    begin
       while i <= v_a loop
          dbms_output.put_line(i);
          i := i +1;
       end loop;
    end;When I see "declare" and "BEGIN" in the same block of code I worry about the standard of code I'm going to see...

Maybe you are looking for

  • Lists of 69 cent songs won't open in iTunes, but other offers will open for preview and purchase.

    I've been trying to link from email to see the songs offered for 69 cents.  The store opens, but when I click on the tabs for #1 Hits or the various genres, I can't view which songs are offered, let only make a purchase.  Other links from email work

  • Disguise outgoing "From" in Mail and/or .Mac mail

    Whether I'm emailing from the web or my computer, Mail won't allow me to mask my outgoing name. I want my clients to get emails from my personal account name [email protected] NOT the Mail account name: [email protected] No matter what I try, there's

  • Prepping for Professional DVD replication

    I am prepping my FCP movie for DVD authoring and I was wondering if the capability of Compressor is equal to that of the software a professional duplication house would be using the encode video?

  • Is there a way to download a Flash file from the web?

    Hello all. I am just wondering if there is a way, similar to downloading QuickTime movies and trailers from the web (using the provided link or its URL) to download a flash file? i.e. a flash-made audio or video? Thanks and cheers

  • Transport Management System Error

    Trying to delete the TMS configuration the following error pops up: "System 0 unknown in transport domain" I'm performing this action on the transport domain controller [DEV] in client 000 with my user [sap_all, sap_new]. Want to set up the transport