Wait for user input in for loop

I'm pretty new to labview and I'm having a hard time figuring out how to do this. Basically, I need the user to press a GO button and data aquisition will take place saving it in an array, then the program will wait for the user to press the GO button again and the data aqusition will add more values to the array, and the whole process will repeat 5 times and finally it will average the values.
To try and figure out how to do this, I tried making a program that loops 5 times and adds a random number to an array with each loop (using shift registers) but I CANNOT figure out how to make each loop iteration wait on the user to press a button. Any advice?

Hi Roger,
you can use a dialog in your for loop, or better you use an event structure to react on user inputs. If you use the event structure you can count the button press events and store them in a shift register. With a compare function you can check if your limit is reached and react on it.
Mike

Similar Messages

  • Need Help waiting for user input.

    I've got a simple card game, which I've pretty much made all with swing. I have a JTextField and a JButton. I want the user to input a number into the textfield and the click the button which fires the action listener. This then takes the text and reads it and set a boolean hasBid to true. I don't want to program to continue until this has happened so I made an empty while(!hasBid) loop. The first time through, the program starts and stop until the user inputs something and click the button. The second time through, however, the whole window freezes. For somereason object aren't even being displayed which are displayed before this while loop. Without the while loop, everything runs fine, but the program won't stop to wait for input.
    So, my question pretty much is how can I get the program to stop for user input in a function which will be called multiple times. I don't want to use a JOptionPane or anyother pop-up box. If my way won't work, I'd really like to know of another way. Thanks for any help!

    you simply need to separate the functionality of your input object and the card game into two threads. as sanbingo said, running in a while loop prevents your GUI from even drawing its components.
    Remember: AWT/Swing is an event driven interface! so only events can/should cause some action to happen.
    i'd properly implement an event listener which is fired when the input is received. the listener is your game class which upon receipt of the event starts playing. when its done, its done, ie doesn't do anything until it receives an new event from your input object.
    thomas

  • How do you keep a VI running while waiting for user input?

    I have a VI that:
    1.  The user enters set points.
    2.  The user starts the VI and the VI sends the set points to an external process via a serial interface.
    3.  The VI  stops running.
    4   The user waits for the external process to complete.
    5.  Repeat sequence. Go to Step 1.
    This works well except for one small problem.  Starting the VI in step 2 causes an external micro controller to reset.  During the reset it will ignore set point commands.  To get around this problem a delay has been added between when the VI opens the serial port and when the VI sends the set points to the external process   Is it possible to keep a VI running continuously in this type of application, thereby eliminating the start up and shut down of the serial interface?
    If yes, how do you keep a VI running while waiting for user input?
    Howard

    The ones for the event structure specifically. I'm posting from my phone. Look at the basic ones for user input. even a simple while loop with a boolean and a case statement would work.

  • How to make Flash to wait for user input

    Hi,
    I found this PHP script, then I made some changes to make it
    FEED the Flash user interface with online user input.
    The main concept of this script is WAITING for user input, so
    it shows the messages and then go to next line and so on.
    The user input go to directly to TEXT file which writes in
    lines, each line has a unique id = (mag_id).
    There "get_msge.php" which works as the middleware between
    FLASH and messages text file.
    The problem, its doesn’t show any data while there are
    data in the text file.
    Help here please, best regards.
    This is the link of
    problem illustartion
    AS is:
    // create an object to store the variables
    varReceiver = new LoadVars();
    // load the variables from the text file
    varReceiver.load("get_msg.php?file_id=1&msg_id=1",
    "POST");
    // trigger something - when the variables finish loading
    varReceiver.onLoad = function(){
    //the variables have finished loading
    if (this.msg_id == 1) {
    _root.xmsg1_swf.text = this.msg;
    _root.xmsg1_ch.text = this.msg;
    gotoAndPlay("line2");
    } else {WAIT }
    PHP is:
    <?php
    //get these values from the FLASH
    $file_id_swf = $_POST ['file_id'];
    $file_name = "messages/messages".$file_id_swf.".txt";
    $msg_id_swf = $_POST ['msg_id'];
    // [0] ."||".[1] ."||".[2] ."||". [3] ."||".[4]."||". [5].
    //$msg_id."||".date."||".time."||".$from."||".$to."||".$msg.
    $fp = fopen ($file_name, 'rb');
    while (!feof ($fp))
    $msg_txt = fgets ($fp, 1024);
    $line = explode ("||", $msg_txt);
    $msg_id = $line[0];
    $from = $line[3];
    $to = $line[4];
    $msg = utf8_encode ($line[5]);
    if ($msg_id == $msg_id_swf)
    echo
    "msg_id=".$msg_id."&from=".$from."&to=".$to."&msg=".$msg;
    }//while
    fclose ($fp);
    ?>

    Well, given the things that you've written, I don't think it
    could. There technically isn't any code in flash that lets it
    "wait." In order to "wait," you must run the script over again
    until some condition is met.
    However, your code does look accurate. Why do you need to
    wait? The onLoad function will be invoked WHEN something is loaded.
    So, I don't see the reason for the "waiting."
    In addition to that, I would like to say that using text
    files isn't that great with flash. I have done this before and
    noticed several problems with using text files. The biggest problem
    is that the text files are cached after being loaded. Every time
    you re-load it again, you will get what you got the first time
    until you reset your cache (ie. close your browser). I suggest
    using MySQL. (Just my thought.)

  • Asking for user input in the middle of a function

    Here's my issue.
    I need to launch and input window in the middle of a function for user input.  Before I can continue through the function I need a response back from the user first.  Psuedo code below:
    function
         function begins
         pop up window is launched to ask for user input
         function continues after users submits input
         user input from pop up window is used in function return value
    Let me know if you need more clarification but this is essentially what I'm attempting to do.

    The way actionScript works it isn’t really designed to work that way
    Is there any reason why you have to only use one function as you have written
    I think you really do need to split up your code into sections that a, set up the pop-up with  event listeners waiting for the input to be completed, trigger the pop up with user input, then have a handler function that then interprets the results of the user action.
    Trying to force the system into a closed loop while waiting will be a bad idea.
    By using a pop-up or an alert window that is set to be modal, you are effectively stopping your application doing anything else until the user input has been completed, but still not locking the app into a closed loop. Imagine what would happen if you did put the system into a closed loop, the mouse movement wouldn’t be updated, the screen wouldn’t refresh and the system wouldn’t be able to handle your user input. the reason for using async model is you are able to let the system still do all its background task (move the mouse, give inputs focus, keep the screen drawn etc) but still tell a part of your app to ‘wait for input’ before carrying on it execution of your logic
    Do you come from another programming language? Maybe one that uses less of an OOP approach? I only ask, as the method you are describing is much more like how I had to program when  I worked on computers years ago as an assembly programmer.
    In actionscript and most other modern languages and Oss you don’t have total control of the system and cant lock it into an action as you describe.
    You need to have an asynchronous approach to situations like you describe and let the system run in the back ground while you are waiting for input (or date from a server for that matter)
    Please excuse me if I am telling you things you already know.
    What exactly is your use case for this? Maybe if we knew exactly what you are working on I might be able to offer a solution that would make sense for your particular situation.
    Hope all is going well and please feel free to contact me if you are stuck

  • How to create an user input variable for customer exit variable? - BW3.5

    Hi Guru,
    I have a requirement for the selection period of my reports. There are 3 possible reporting periods which should be user selectable:
    1. Month: Current reporting month
    2. Fiscal Year to Date
    3. Project Year to Date
    Here I need 2 variable to do these, 1 customer exit and 1 user input variable. I have created a variable customer exit to calculate all these requirement. But can any1 tell on how to create the user input variable for my customer exit? I need a user input variable with drop down list like below.
    01-Current month
    02- Fiscal Year to Date
    03-Project Year to Date
    I have create a new master data for this variable, but it's not working. What I need now is a standalone master data which do not need to link to any exiting records. Can any1 tell me how to create this?

    Just go to the definition of the variable for which you have created a customer exit. There you will find a check box for "Ready for Input". Just tick that checkbox and the variable will be available as a selection variable in the reports selection screen.
    Regards,
    Yogesh

  • Create a screen for user input in BI

    Hi Experts,
    I want to know can i creat a screen for user input in BI with module pool programing
    and i want to store the data in ztable in SAP-BI.
    Moderator message: please search for available documentation, these forums are no substitute for ABAP training.
    Edited by: Thomas Zloch on Dec 10, 2010 8:37 PM

    I'm afraid that I cannot get it. I had a look at the docs you suggested before posting, and still, no luck (...)
    JOptionPane.showMessageDialog(dialog, "Please input info");Can you please tell me what I'm doing wrong and I cannot add the JDialog to the JOptionPane?Re-read the API and tutorial. JOptionPane is meant specifically to spare you from instantiating manually a JDialog. The showXxxDialog(...) methods do create a JDialog of their own, based on the contents supplied as arguments.
    In particular, using the 2-arguments variation showMessageDialog(Component parentComponent, Object message):
    - The first argument parentComponent is not be the dialog you want to display, but the component over which you want the dialog to appear. The most typical value are this or null.
    - The second argument is the "message" to display, but as described in the API, it can be a JComponent, that is, even a JPanel with child widgets (in a word, a JPanel containing the specific form you'd display in the dialog if you were writing the dialog manually).
    Again, at the risk of insisting densely, I'm only quoting the API an tutorial, so please read them attentively.
    Edited by: jduprez on Nov 2, 2009 2:29 PM - Sorry Kevin, hadn't seen you latest reply. I completely subscribe to the thought process you recommend.
    Edited by: jduprez on Nov 2, 2009 2:32 PM
    Thinking about it further, I don't completely subscribe... Indeed it looks like a bad idea to make the OP wonder about dialog.setVisible() when JOptionPane enables him to forget about the hand-made dialog. I stand by my own advice ("JDialog" should not even appear in this code extract).

  • "catching" a prompt for user input and answering it through zenity?

    I'm trying to write a script (or multiple scripts) that will allow me to use command-line only applications via user defined actions in my file manager without having to open a terminal. Now I realize this basic functionality is already available, but as it stands I am unable to respond to command-line prompts for user input without opening a terminal. Is it possible to write a shell script that would act as a wrapper and allow me to use zenity (or another popup program) to respond to such queries?
    For example if I used a command-line program that prompted me for a password, could I "catch" that prompt with a shell script and answer it through another program, such as zenity?
    Last edited by falconheart (2011-01-16 22:37:25)

    The easier way to do this is to collect the info with zenity first, then pass it on the command line.  If the program insists on prompting, then you could try feeding it the info with redirection if it accepts it from stdin.  For example
    command < info.txt
    where info.txt is a temp file created by your script which contains whatever you want entered into the prompts.  This will work in some cases.

  • How to prompt for user input in Forms

    How do I prompt for user input in Forms?
    I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?
    If the user chooses to input the value I want to update a set of database fields with the value.
    I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?

    Desgordon,
    This can be accomplished by displaying your message to the user using an Alert. I use 3 different Alerts (Note, Caution and Stop) in my forms and they are inherited from a central source file (such as an Object Library or a Template Form) so they can be used by all of my Forms. You can set the text of the Alert using the SET_ALERT_PROPERTY() built-in and capture what button the user presses with the SHOW_ALERT() built-in. Additionally, if you need more than one button to be displayed in an alert, you use the SET_ALERT_BUTTON_PROPERTY() built-in to rename the default button or to add up to a total of three buttons in the alert. Here's an example:
    DECLARE
       Alert_ID       ALERT;
       v_AlertType    VARCHAR2(10) := 'CAUTION';
       v_AlertTitle     VARCHAR2(25);
       v_AlertText    VARCHAR2(150);
       n_AlertButton  NUMBER;
    BEGIN
       v_AlertTitle := 'Title of Alert';
       v_AlertText := 'This is message to the user.';
       /* Code leading up to the decision point. */
       alert_id := FIND_ALERT(v_AlertType);
       /* Note: I only set the Label of Button 2 because the default button 1 label is 'OK' */
       SET_ALERT_BUTTON_PROPERTY(v_AlertType, ALERT_BUTTON2, LABEL, 'Cancel');
       SET_ALERT_PROPERTY(Alert_ID, v_AlertTitle, v_AlertText);
       n_AlertButton := SHOW_ALERT(Alert_ID);
      /* Now I can test the value of n_AlertButton for 1 or 2 to find out what button the user selected. */
      IF ( n_AlertButton = 1 ) THEN
         /* Do something, because the user selected 'OK' */
      ELSE
         /* It is assumed at this point that the user selected 'CANCEL' */
         /* Stop processing any further. */
         RAISE form_trigger_error;
      END IF;
    END:Hope this helps.
    Craig...
    -- If my response or the response of another answers your question, please mark the response accordingly. Thanks!

  • How to prompt for user input in PL/SQL

    How do I prompt for user input in PL/SQL?
    I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?
    If the user chooses to input the value I want to update a set of database fields with the value.
    I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?
    Edited by: desgordon on Sep 3, 2008 10:33 AM

    desgordon wrote:
    How do I prompt for user input in PL/SQL?
    I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?OK, you're doing that in Forms...
    >
    If the user chooses to input the value I want to update a set of database fields with the value.Write PL/SQL procedure for this purpose...
    >
    I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?Not clear what you mean with view?
    But if you call your procedure in that button then yes 'control will be passed back to the code'...
    Cheers!
    Edited by: Faust on Sep 3, 2008 7:57 PM
    Too slow...

  • How to put a little textbox in a regular applet window for user input

    Hi i was just wondering if anybody knows how to draw a text box, (for user input), in a applet window and be able to put it in a specific spot, like when you draw a rectangle.
    I have searched the web and have not found any answers, but i have seen projects that do this but they dont have the source code.

    JTextField?

  • Article on "Enabling PDFs for User Input"

    My article on "Enabling PDFs for User Input" is now available at
    http://www.front-runner.com/tools_and_resources/articles/enabling_pdfs.html
    (with links to sample PDFs, demonstrating different approaches).
    Shlomo Perets
    MicroType, FrameMaker/Acrobat training & consulting
    "24 easy ways to improve your PDFs with FrameMaker-to-Acrobat TimeSavers/Assistants",
    http://www.microtype.com/ImprovePDF.html

    Hi,
    Yes, there is such a functionallity built into the system, but it's not enabled by default. Because of this, it's not supported to enable it. For more information take a look at Antons blogpost:
    http://blog.scsmsolutions.com/2013/02/sla-in-scsm-2012-part-3-hidden-features/
    Regards
    //Anders
    Anders Asp | Lumagate | www.lumagate.com | Sweden | My blog: www.scsm.se

  • Is there a difference for user agent string for firefox desktop & firefox mobile?

    Is there a difference for user agent string for firefox desktop & firefox mobile?

    Yes. All versions of mobile Firefox have "Fennec" in the useragent string. For example:
    Mozilla/5.0 (Android; Linux armv7l; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1
    For more details and examples, please see this article:
    http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/

  • WORKFLOW PROCESS IS NOT WAITING FOR USER INPUT LIKE RE-ASSIGN FUNCTION

    I am using Stand alone Workflow 2.6, In my workflow process
    which is an Issue tracking system which is working fine. On Enhancement I would like to create my own RE-ASSIGN function which will, Change the ownership of an issue totally to other user.
    For this I Created a package(CHANGE_OWNER.CREATE)which will show list of Users and Comment field(Just like Re-Assign).
    Here user can pick other user, and add comment,
    once submit for that Item key I am updating the workflow notification table so that paritcular issue ownership will be changed.
    In my workflow process I created a lookup code called "Change Owner". On click of Change Owner it will call the Function
    in workflow process which will call CHANGE_OWNER.CREATE, here
    the workflow process supposed to wait and get the User to be
    changed. BUT THE PROCESS IS NOT WAITING, IT JUST DISPLAYED THE
    SCREEN AND CONTINUED THE WORKFLOW PROCESS. I WANT THE MY
    WORKFLOW PROCESS TO BE ACT AS RE-ASSINGN BUTTON WHICH WILL WAIT
    FOR THE USER INPUT.
    HOW TO DO IT.
    Thanks
    Bala.

    Hi Bala
    What enhancements were you adding to the Workflow Reassign/Delegate feature, which included being able to add comments? A good idea is to look for any differences between how workflow implements the reassign feature, and your customization.
    Also, make sure you only use the Public documented PL/SQL APIs and do not update the tables directly to ensure no Support or Upgrade Issues.
    Cheers
    Mark
    I am using Stand alone Workflow 2.6, In my workflow process
    which is an Issue tracking system which is working fine. On Enhancement I would like to create my own RE-ASSIGN function which will, Change the ownership of an issue totally to other user.
    For this I Created a package(CHANGE_OWNER.CREATE)which will show list of Users and Comment field(Just like Re-Assign).
    Here user can pick other user, and add comment,
    once submit for that Item key I am updating the workflow notification table so that paritcular issue ownership will be changed.
    In my workflow process I created a lookup code called "Change Owner". On click of Change Owner it will call the Function
    in workflow process which will call CHANGE_OWNER.CREATE, here
    the workflow process supposed to wait and get the User to be
    changed. BUT THE PROCESS IS NOT WAITING, IT JUST DISPLAYED THE
    SCREEN AND CONTINUED THE WORKFLOW PROCESS. I WANT THE MY
    WORKFLOW PROCESS TO BE ACT AS RE-ASSINGN BUTTON WHICH WILL WAIT
    FOR THE USER INPUT.
    HOW TO DO IT.
    Thanks
    Bala.

  • Modifying user input in for loop

    Hello,
    I am making a program in order to control two velmex motors. As part of my program, I have two nested for loops. The inner for loop formats a user specified input in ascii commands and the outer loop tells the program how many times to run that specific inner loop pattern. 
    I want to modify the program so that two motors work together in a "snake pattern". In other words, the first outer loop should take the original user input, but then the second time the outer loop runs the direction of one of the motors (all of the associated values with one motor are stored in an individual cluster and these clusters are sorted and placed into an array), should be reveresed by mulltiplying the step size * -1. The third time the outer loop runs, the direction of one the motors (the same motor) should be reveresed again so it is moving in its original direction etc.
    Hope that made sense...
    I have attached my code for clarification - any help would be really appreciated
    Thanks,
    Mridu

    mnanda98 wrote:
    Hi RavensFan,
    Do you mean I need to wire a constant into the VISA read?
    Isn't that exactly what I said?
    Also I am making progess, but now when I run the program I get the error "timeout expired before the operation completed". From what I understand, the timeout would only expire if it is not picking up on the termination character, which I have put in.. Can you look at my code maybe and tell me what may be the problem?
    It looks like you've set the termination character to be a carriage retrrun (decimal 13) just fine.  So if you are getting a timeout error, that means you are either not sending the commands correctly and the device is not responding, or the termination character is not actually a carriage return like you said.
    Do you have any software that the vendor of the device  might have supplied that can prove to you that it is communicating correctly?  Is any data returned in the string indicators when it finally times out?
    Thanks in advance,
    Mridu
     And why do you still have the VISA Close inside the loop closing the port on each iteration?  It belongs after the while loop.

Maybe you are looking for

  • PE8 won't allow transition to be applied

    I've seen this before from time to time, where I try to drag a transition to the timeline between two clips and it simply disappears when I let go of the mouse... in what cases does PE8, by design, prevent a transition from being applied between clip

  • Survey:  Automated Upgrade of Oracle Databases

    Hi Folks, We would like to invite interested customers/partners to participate in a survey that we have created, to gather feedback and requirements input about automated upgrade of Oracle databases. If you would like to participate in this survey, p

  • Google Chrome and instability

    About two weeks ago I decided to switch from using Firefox (because it was much too piggish with resources) to Chrome.  At first, this was wonderful -- Chrome was lightweight and speedy, but starting a few days later all sorts of bad things began hap

  • Service Level Objectives failing

    Hi, I have created a number of Service Level Objectives for incident resolution times based on priority (in SCSM 2012 sp1).  They were all working fine but some thing has happened and now they are not being applied to the incidents that should be get

  • Powerbook will turn on but won't get past grey apple screen

    My powerbook will turn on but it will never get to the operating system screen where you enter a password. I don't know what to do and sometimes it will get to the all blue screen but not past that... Any help would be greatly appreciated. Also, is t