How to make a button to stop and run a for loop?

How to make a button to stop and run a for loop?  and if it is stopped it shall start from where i t stopped.

Your VI has some very fundamental flaws.
The start/stop button is outside the FOR loop, thus it will NOT get read during execution of the FOR loop, but only before the FOR loop starts. Think dataflow!
Thus the terminal of the start/stop button belongs inside the FOR loop.
Your FOR loop iterates 20x, which probably takes about a nanosecond. You will NOT be fast enough to reliably press the start/stop button during a specific iteration of the FOR loop.
Your code does not "stop and run" a FOR loop (sic). The loop always spins, but executes an empty case when "Stopped". I guess that's what you actually want?
Once you solve (2), the x indicator will contain a random value whenever you "stop".
As soon as the 20 iterations complete, the outer while loop spin an things start over, another nanosecond later.
Place e.g. a 500ms wait inside the FOR loop to solve this.
Don't place terminals of indicators on top of formula nodes.
Your formula does not produce any output, so really has no purpose.
Use a real "stop" button to terminate the while loop (mechanical action: latch when released). Right now you are using a plain switch, which does not reset to false before the next run. This means that you need to manually reset it before running the program again.
It is oftern useful to operate the VI in execution highlighting mode. You will immediately see that your button does not get read during execution of the FOR loop. Try it!
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • How to make a button to stop and run a while loop?

    Hi all,
    I am a beginner in the Labview. I did a program that contains a while loop, its stop condition is connected to button. I selected “switch when pressed” to be the operation of this button. Our teacher asked us to make this button stops the loop if it is pressed and its name is converted to run instead of stop. And if it is pressed then again it starts the loop from the point it stopped in.
    Can anybody help me, please?

    First, please use a smaller font when composing your messages.
    You will need two while loops.  An inner loop which has its stop terminal attached to the stop button.  Put that in the False case of a case structure.  Wire a local variable of that stop button to the case selector of the case structure.  Put the case selector inside another while loop which is the one that keeps the program running no matter what the state of the original Stop button.  You will need a master stop button to stop the outer loop when you are ready to end the whole program.  Don't forget to put small millisecond waits in each of the loops so that the loops don't eat up all the CPU resources.
    For that stop button, you could rename the True title to Run, so that when it is pressed to stop the inner loop, the button will show the word Run.  Pressing it again pops it back out, allows the false case to execute and the innermost while loop to run.
    You could also change the words on the buttons by using property nodes.

  • How to stop and start a for loop

    I've got code and a for loop running in a while loop.  What I need to do is simply pause the operation of the for loop until an requirement is met, and but maintain its iteration position throughout each pause interval (not necessarily timed, just paused until the next requirement is met).  I've tried wiring a boolean to the "continue if true" terminal of the for loop, but the iteration count restarts to 0 when the loop is started again.  Is there a way to stop the for loop, and continue at the particular iteration it is at?
    Solved!
    Go to Solution.

    Breakpoints, whether normal or conditional, are just meant for debugging of your code.  I had the sense from your question that the pausing you want to do is a part of normal operation of your code.  I would NOT recommend using a breakpoint for that situation.  It would bring up the block diagram showing the breakpoint when it occurs.  A user besides the programmer would not know what to do in that case.
     Yes, both the inner and outer loops would have shift registers.
    Putting a case structure with a small while loop inside the "Pausing Case" is doable.  It just depends on what you are doing or waiting for while the program operation is "paused".

  • How to make powermac G4 400GHz faster and run smoother.

    I really want to make my Power Mac G4 much faster and run smoother, can someone help me do this.
    P.S. I'm running mac OS X 10.4.11 and I'm trying to install mac OS X 10.6 snow leopard will upgrading my OS help improve performance.

    dragon,
    First thing to do, and the cheapest, is more RAM. It's not cool to recommend retailers, etc....but you really want to get the right stuff. Macs can be finicky about RAM. You can get the right stuff in many places...IF you know what you're doing. That being said, most 'pros' here in Discussions recommend macsales.com (OWC) and crucial.com because you'll get the right stuff at decent prices. Both have memory 'advisors', where you type in your machine type and get recommendations for the correct memory. Do that yourself, even if you're not ready to buy today.
    macsales.com has 512mb for about $30. Crucial wants $60; dunno why; they used to be comparable. One plan, on your limited budge, would be to get one 512mb stick; then save up and buy THE SAME product when you've saved up $30 more. I wouldn't mix. It can be done but you'll save yourself some grief just buying the same sticks from the same place. You'll see a pretty good improvement if you go to 1GB+.
    You'll also see pretty good performance if you limit the number of apps you install, particularly "third party plugins". Keep your Mac lean and mean and it'll perform well for years. Be sure to run Permissions Repair EVERY TIME you install an app. I say this because that 60GB HD will fill up pretty fast. Maybe it'd be better just to get the one 512MB stick, giving you 1.5GB RAM. Then, save up for a bigger HDD. You'll need those two upgrades before even thinking of a CPU upgrade.
    Get the free utility Macaroni and let it run daily, weekly, monthly tasks. Read thru other posts here in the 'Using ur PMac G4' and "Exanding ur PMac G4".
    Please come back if you have any more questions. HTH

  • Stopping and Continuing a For Loop

    I have a problem on looping. This is a game of Whack the Mole. First, there is a for loop that is in charge of generating different hole positions for my moles. I want it so that the loop will (1) Generate a number (2) Stop the generating (3) Based on the number that was just generated, run a function for it. Once done running the function, then (4)Start the second round of generating another number......and it goes on for 9 rounds. I have my code here.
    var molePosX:Array = [166.90, 494.8, 810.7];
    var molePosY:Array = [282.55, 512.45, 730.35];
    var moleInUse:Boolean = false;
    if (moleInUse == false){
    for(var i:uint = 1; i<10; i++){
              var randomHole:Number = Math.floor(Math.random()*10)+1; //Generate 10 number
              trace(randomHole);
              switch (randomHole){
              case 1: trace("1");
              moleRun(molePosX[0],molePosY[0]);
              break;
              case 2: trace("2");
              moleRun(molePosX[1],molePosY[0]);
              break;
              case 3: trace("3");
              moleRun(molePosX[2],molePosY[0]);
              break;
              case 4: trace("4");
              moleRun(molePosX[0],molePosY[1]);
              break;
              case 5: trace("5");
              moleRun(molePosX[1],molePosY[1]);
              break;
              case 6: trace("6");
              moleRun(molePosX[2],molePosY[1]);
              break;
              case 7: trace("7");
              moleRun(molePosX[0],molePosY[2]);
              break;
              case 8: trace("8");
              moleRun(molePosX[1],molePosY[2]);
              break;
              case 9: trace("9");
              moleRun(molePosX[2],molePosY[2]);
              break;
              case 10: trace("10");
              break;
              function moleRun(xPos:Number,yPos:Number){
                        moleInUse = true;
                        var mole2:Mole = new Mole();
                        mole2.x = xPos;
                        mole2.y = yPos;
                        addChild(mole2);
                        moleInUse = false;
    Thank you very much!

    i'm not sure you want to do that without staggering your mole creation but if you do, you can use:
    var molePosX:Array = [166.90, 494.8, 810.7];
    var molePosY:Array = [282.55, 512.45, 730.35];
    createMoleF(9);
    function createMoleF(n:int):void{
    for(var i:uint = 0; i<n; i++){
              moleRun(Math.floor(Math.random()*molePosX.length),Math.floor(Math.random()*molePosY));
              function moleRun(xPos:Number,yPos:Number){
                        var mole2:Mole = new Mole();
                        mole2.x = xPos;
                        mole2.y = yPos;
                        addChild(mole2);
    Thank you very much!

  • IDVD'08: how to make back button, video chapters and stretch pictures?

    Hi!
    I am new to iDVD'08 so I have 4 questions:
    1) In main menu I created a submenu called "video". It opens new screen with a list of videos. I want to have a back button on this screen too. It should return to a main menu. How can I make it?
    2) I have one big movie in iMovie'08 and want to burn it in iDVD'08 with chapters. So that different events in this big movie could be easily selected. I dont want to crop with big movie into pieces in iMovie. So how can I create such a buttons that point to different parts of movie?
    3) All that dropzones and buttons with preview are fantastic... But! How can I tune photo assigned to them? You know that picture tuning dialog: when you select photo and then can zoom in/out and move photo. Where such a dialog in iDVD?
    4) If I create a button with preview (for example, with a shape of heart) for submenu than folder icon is displayed in that preview. Hoe to place photo or movie just on a preview zone of such button?

    Q: I was curious is there a PRO analog of iMovie and iDVD like Aperture comparing to iPhoto.
    A: Your only options of apple video editing software (with the exception of QT Pro) are as follows:
    1. iMovie 7 (consumer grade video editing software)
    2. iMovie 6 (Free Download from apple's web site assuming you own iLife'08)
    http://support.apple.com/downloads/iMovieHD6
    Also consumer grade however this software is actually better for adding custom chapter markers, exporting back to the camcorder when needed, working with a Timeline, etc.
    3. FCE (I consider this app as pro-sumer software mainly because it's better than iMovie and very much like FCP; with the exception that it cannot be used to open existing FCP projects. That can only be done with apple's FCS 2)
    4. FCP (part of FCS 2) Apple's Professional / High end Video editing software.
    Message was edited by: SDMacuser

  • How to make the whole movie stop

    Hi,
    I want to make a button open a new scene,
    I have that working but it keeps looping,
    How to make the whole movie stop at the end of scene 2,
    Ive tried putting stop(); but that brings errors,
    I want to stop the whole movie, How would i do this?

    click an empty part of the stage in the frame where you want the timeline to stop and in the actions panel type:
    stop();

  • How to make the buttons INVISIBLE in the Application toolbar

    Hi All,
    I have a requirement to create a button in the Application toolbar of the Module Pool Screen. The field should be made Invisible by default. and it should be displayed based on one condition.
    Could you please let me know how to make that particular button INVISIBLE. I think we can make it invisible by using EXCLUDING statement. But, How to make the button VISIBLE again when the check is satisfied.
    I found from the portal that the FM 'VIEW_SET_PF_STATUS' can be used to make a button INVISIBLE. Could anyone help me out how to pass the parameters to this Function module?
    or is there any Function Module available to make the button VISIBLE and INVISIBLE? Please help me on this issues.
    Is there any possibility to make the button VISIBLE or INVISIBLE as we do for the screen fields using LOOP AT SCREEN..?
    Thank you in advance.
    Regards.
    Paddu.

    Hi,
    Try to use below in the PBO module status_0100 OUTPUT.
    DATA t_fcode TYPE TABLE OF sy-ucomm.
    refresh t_fcode[].
    APPEND 'Function code name of the button' TO t_fcode. 
    Check the condition here for which you want to make field visible.
        DELETE FCODE of the button from T_FCODE table
      ENDIF.
      SET PF-STATUS 'STATUS_0100' EXCLUDING t_fcode.

  • How to make "Utility" button in Printer Setup Utility available

    There, i add a printer in the Printer Setup Utility and select it. i want to open printer utility, but the "Utility"
    button in Printer Setup Utility is dimmed. In addition,
    "Printer\Configure printer" in the Printer Setup Utility menu is also dimmed.
    How to make "Utility" button in Printer Setup Utility available?
    Thanks in advance.

    Hi Jiong,
    That button is to acess the printer utility for that particular printer, not all printers come with a utility. If you have the disk that came with your printer, you can see if it has a Macintosh driver, if it does then it mimght have the utility with it. It's pretty hard to run the utility on its own, its burried somewhere in the system so that's why you have that menu item. You can alternatively go on the internet and download the latest driver, which might have a utility. All the utility will do will give you options to check nozzle patterns, alighnement, ink tank levels, and cleaning options - just mimnor maintenence junk, non-essentials, etc. I think Tiger just comes with a whole heap of generic drivers for different printer lines, can't say for sure.
    I wouldn't worry about it, especially if you have a relatively old printer.
    Hope that helps
    DKR

  • How to make it selected when clicked and open popup

    Hi,
    I 've a form in the parent page with many form elements.
    I've 2 radio buttons with values "Yes" and "No". I am opening a modal popup when clicked on "Yes" radio button. The modal popup is opening fine.
    But when I click "Yes", it' s not selected. After modal popup is closed, when I return to parent page, the option "Yes" is still not selected.
    How to make it selected when clicked and open popup?

    Perhaps try moving the application to your preferred desktop and then right-click it's dock icon > options > Assign to This Desktop.

  • How to code a button to play and pause sound using load sound?

    how to code a button to play and pause sound using load sound?I have used load sound methos to attach the sound.Can anyone help me?

    Hey thnx,
    I have used this code on sound's button's frame.and my stop n play button is on another screen.main sound button and stop button is on diffrent screen.
    Here is my code-
    stop();
    adaDrut1.onRelease = function () {
              mySoundC = new Sound(this);
              mySoundC.loadSound("F#/Bhajni1.ark", true);
    mySoundC.onSoundComplete = function() {
    _root.mySoundC.start(0,999); }
             gotoAndPlay("play2");
            _global.myTaalLaya = "Low1";
    adaDrut1 is a sound button.And there are lot of buttons with diffrent sound.
    Thanks..

  • How to make a button load a sprite from library??

    PLEASE HELP!!
    Hey everyone.. iv been looking for help for a few weeks but cant seem to find the awnsers
    I am trying to create a newspaper that consists of four pages. Each   page i have created and are sitting in the library as sprites. Each page   has buttons that need linking so that when pressed it loads the next   page or page that i want. This is the part i am confused with =/ how do i   make the buttons on each page load the next page (sprite) from the   library??
    Basically i want to no how to make a button load a sprite from the library when clicked. Does anyone no the script for this?
    Thanks for any help

    A question arises as to whether or not you are posting in the right forum.  Sprites are AS3 objects.
    If you want to add movieclips to the stage from the library using AS2, then you need to assign them each an Identifier via right clicking them in the library and selecting the Linkage option... from there you slect the option to Export for Actionscript and then assign the Identifier.
    You then use the attachMovie() method to make use of that Identifier to dynamically load the library object.

  • HOW TO MAKE ROUND BUTTON

    HI PLS TELL ME HOW TO MAKE ROUND BUTTON ON FORM.

    Rounded end buttons (e.g. Oracle Look and feel) are do-able in both 6i and 9i using PJCs in the 9i demos see the rollover button example, in 6i I seem to remember that there is a RoundedButton sample in the demos.
    Both sets of demos can be downloaded from http://otn.oracle.com/products/forms.
    If you want circular buttons then you'd have to use an Image for that.

  • How to make a Button to work Actively even if there is a mandatory field..?

    Hi All..
    How to make a Button to work Actively even if there is a mandatory field to be fulfilled..???
    I am badly in need of this logic, as i have to incorporate in my code..
    Points will be rewarded without fail..

    Hi Pavan,
    I also faced the same requirement. U can do one thing like remove the obligatory keyword of that parameter/select-option. U can handle the same using the program in at selection-screen event. See this sample of code,
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_land1 for T005-LAND1 <b>[Needs to be mandatory]</b>                 no intervals no-extension.
    SELECT-OPTIONS:  s_panid FOR zoindex_val-zopanid.
    SELECT-OPTIONS:  s_effdat FOR zoexchrate-zedate.
    SELECTION-SCREEN END OF BLOCK b2.
    *-- AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
    *-- Obligatory Country Code
      IF s_land1[] IS INITIAL.
        MESSAGE e050 WITH text-050.
                     "Please select the Country Code
      ENDIF.
    So whenever u do F8/Enter other than that push button, it will prompt u to enter the country code first then only u can proceed.
    Hope this would help u in some way. Please do reward the helpful answers.

  • HT5312 im trying to make a purchase on itunes and its asking for my security question and i dont remember them its been years since i made this account how can i reset them

    im trying to make a purchase on itunes and its asking for my security question and i dont remember them its been years since i made this account how can i reset them

    You need to ask Apple to reset your security questions; ways of contacting them include clicking here and picking a method for your country, phoning AppleCare and asking for the Account Security team, and filling out and submitting this form.
    (98991)

Maybe you are looking for