Why is my variable incrementing multiple times?

In my application I need to increment a variable when a certain condition is met so I have a case statement which checks whether the condition is true then increments a variable. However the variable is increment for the entire time that the condition is met. How can I restrict this to only increment one time per occasion of the condition being true. I've tried while and for loops that execute only one time and nothing seems to work.

Or you could do it similar to this.
Joe.
"NOTHING IS EVER EASY"
Attachments:
Try this.vi ‏26 KB

Similar Messages

  • Why are my appointments listed multiple times?

    Why are my appointments listed multiple times?

    I noticed this today but I didn't even use outlook.  I made all appointments in EST/EDT.  Currently I'm on a business trip in Poland and all the times changed 6 hours ahead (the time zone in poland)... so now while planning things back home, everything is screwed up because I thought my appointments were 6 hours later then they were...
    This is a HUGE issue.... this will cause major headaches for business travelers and needs to be looked at ASAP.  But I can't even find a way to file a bug report with apple and let them know.  Not impressed one bit with this.

  • Why one interrupt request causes multiple times of responses (isr)?

    Hi, Folks
    I have a GPCT0 timer which will generate interrupt. with a oscilloscope, every time I run the code I saw a pulse was generated at the G0 output, but the isr run 51 times when I open the NI SPY to monitor it. When I turned off the NI SPY, it happened 6 to 8 times. I enabled the visa event, then configured the timer and turned on the hardware interrupt. Here is the code in main:
    // enable the G0_TC interrupt
     theSTC->Interrupt_A_Enable.setG0_TC_Interrupt_Ena​ble(1);
     theSTC->Interrupt_A_Enable.setG0_Gate_Interrupt_E​nable(0);
     theSTC->Interrupt_A_Enable.flush();
     theSTC->Analog_Trigger_Etc.setGPFO_0_Output_Selec​t(0);
     theSTC->Analog_Trigger_Etc.setGPFO_0_Output_Enabl​e(1);
     theSTC->Analog_Trigger_Etc.flush();
    // enable the interrupt A
     theSTC->Interrupt_Control.setRegister(0); // reset complete register
     theSTC->Interrupt_Control.setInterrupt_Output_Pol​arity(theSTC->Interrupt_Control.kInterrupt_Output_​PolarityActive_Low);  
     theSTC->Interrupt_Control.setInterrupt_A_Output_S​elect(0);  
     theSTC->Interrupt_Control.setInterrupt_A_Enable(1​);
     theSTC->Interrupt_Control.flush();
    // start to run the timer
     theSTC->G0_Command.writeG0_Arm(1);
    Here is code in the isr:
    ViStatus _VI_FUNCH IHandler(ViSession vi, ViEventType etype, ViEvent event, ViAddr uhandle)
     tAddressSpace  Bar0, Bar1;
     tESeries *board;
     tSTC *theSTC;
     tMITE *mite;
     Bar0 = bus->createAddressSpace(kPCI_BAR0);
     Bar1 = bus->createAddressSpace(kPCI_BAR1);
     mite = new tMITE(Bar0);
     board = new tESeries(Bar1);
     theSTC = new tSTC(Bar1);
     i = i++;
     theSTC->Interrupt_A_Ack.writeG0_TC_Interrupt_Ack(​1);
     theSTC->Interrupt_A_Enable.writeG0_TC_Interrupt_E​nable(0);
     theSTC->Interrupt_Control.writeInterrupt_A_Enable​(0);
    (function code here)
     mite->LocalCpuInterruptMask2.setSetCpuIntIE(1);
     delete mite;
     delete theSTC;
     delete board;
     bus->destroyAddressSpace(Bar0);
     bus->destroyAddressSpace(Bar1);
     return VI_SUCCESS;
    I suspect that there may be someting wrong with data passing between main and isr, don't know for sure.
    Any help and advice will be appreciated greatly.
    Best regards,
    George

    Hi George,
    I'm confused on what the interrupt handler is trying to do.   By disabling interrupts you should not get any more interrupts after the first interrupt is handle.  I think you are saying the problem is that the interrupt only occurs 51 times, but I don't know how it happens more than once!?.  Is there something missing?
    One thing not related to the device programming... the interrupt event callback should not be create and destroy (new/delete) the chip objects eveytime is called for these reasons:
    - The chipobjects maintain softcopies of the registers and they model the state of the hardware.  The new object does not represent the currently configured device.  There should be one instance of the chip the object is representing.  You should create one instance of the tSTC because there's one STC in the device.
    - Memory operations can be very expensive.  A lot of time is consumed creating and destrying these objects.  Add to that the constructor and destructors of each object, which are called for every new and delete.
    To solve both problems use the 'userHandle' parameter in viInstallHandler, from the description:
    Applications can specify a value in the userHandle parameter
    that is passed to the handler on its invocation. VISA identifies handlers
    uniquely using the handler reference and this value.
    This userHandle provides context for your interrupt callback.  If you only need the STC object to service the interrupt you can pass a pointer to the STC object as the user handle.  In your handler you would use the userHandle argument to get to the STC object:
    ViStatus _VI_FUNCH IHandler(ViSession vi, ViEventType etype, ViEvent event, ViAddr uhandle)
        tSTC *stc;
        stc = (tSTC *) uhandle;
        stc->...
    Diego

  • Photoshop is opening multiple times...WHY??? (please help).

    When I double click on an image (from Bridge for example) to open in Photoshop it will open up CS6 and then sometimes when I open another image, instead of opening up in the same open Photoshop program, it will open up an additional Photoshop program.  Both CS6, Version 13.0.6 x64.  Super frustrating when sitting with a client and trying to add an image to a document and it opens up in a different program...   Is there a way to see where Photoshop is opening from?  Why would CS6 be opening multiple times???
    I don't think I noticed this happening before I upgraded to Mavericks (yes, this has been happening for a while).  I also have a back-up program called SuperDuper that mirrors my system on a separate hard drive.  Could Photoshop be opening from there, too?
    Thanks for any possible help!
    Deron

    Use Lion Recovery to reinstall the Mac OS X.

  • Oracle Object Type Constructor Called Multiple Times

    I have an object type with a custom constructor. In SQL, when I reference the attributes the constructor is called multiple times in Oracle 11.2.0.4.
    Why is the constructor called multiple times?
    How do I stop it?
    My current work around is to reference the attributes and use the /*+ materialize */ hint.
    Problem Setup
        create or replace type Foo as object
          Bar1 NUMBER,
          Bar2 NUMBER,
          Bar3 NUMBER,
          CONSTRUCTOR FUNCTION Foo(p_Bar1 NUMBER, p_Bar2 NUMBER, p_Bar3 NUMBER)
            RETURN SELF AS RESULT
            DETERMINISTIC
        create or replace type body Foo is
          -- Member procedures and functions
          CONSTRUCTOR FUNCTION Foo(p_Bar1 NUMBER, p_Bar2 NUMBER, p_Bar3 NUMBER)
            RETURN SELF AS RESULT
            DETERMINISTIC
          AS
          BEGIN
            SELF.Bar1 := p_Bar1;
            SELF.Bar2 := p_Bar2;
            SELF.Bar3 := p_Bar3;
            dbms_output.put_line('Foo Constructor Called');
            RETURN;
          END;
        end;
    Problem
        -- Constructor is called 6 times!
        -- Once for each column and once for each predicate in the where clause.
        SELECT x.f.bar1 AS bar1, x.f.bar2 AS bar2, x.f.bar3 AS bar3, f
        FROM (
          SELECT foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3) f
          FROM dual d
        ) x
        WHERE x.f.bar1 = x.f.bar1 AND x.f.bar2 = x.f.bar2
    Output
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Foo Constructor Called
    Workaround
        -- Work Around
        -- Constructor is called 3 times
        -- Once for each column in the inline view.
        -- Note, I removed column f (the object type) because it's not compatible with the materialize hint.
        WITH y AS (
          SELECT /*+ materialize */ x.f.bar1 AS bar1, x.f.bar2 AS bar2, x.f.bar3 AS bar3
          FROM (
            SELECT foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3) f
            FROM dual d
          ) x
        SELECT y.bar1, y.bar2, y.bar3
        FROM y
        WHERE y.bar1 = y.bar1 AND y.bar2 = y.bar2

    Another work-around is described in this thread... Accessing fields of a custom object type... which makes use of a collection type combined with the TABLE operator, like so...
    create or replace type FooTable as table of Foo;
    SELECT x.bar1 AS bar1, x.bar2 AS bar2, x.bar3 AS bar3, value(x) f
        FROM table(FooTable(
          foo(p_Bar1 => 1, p_Bar2 => 2, p_Bar3 => 3)
        )) x
        WHERE x.bar1 = x.bar1 AND x.bar2 = x.bar2
    BAR1 BAR2 BAR2 F
    1    2    3    (1, 2, 3)
    Foo Constructor Called
    Hope that helps...
    Gerard

  • HT1911 Why does Itunes have me logging in multiple times to buy a song? Somehow, my account got disabled now. It also shows that I am logged in....?

    Why does itunes have me logging in multiple times to buy a song? I can access everything else fine, but now my account is disabled for some reason although my password was entered correctly... help

    I've seen a couple of other threads over the last 10 minutes posting similar problems, so it appears to have affected other people as well - the poster on the first thread has now posted again saying that it's now working for him, so you could give it another try.
    Edit : your reply appeared as I was attempting to post this

  • Why is Apple TV showing the same computer multiple times for Home Sharing?

    Why is my Apple TV showing the same computer multiple times for Home Sharing? Also have connectivity issues. Sometimes will lose signal.
    JonRod's music
    JonRod's music
    JonRod's music
    JonRod's music
    JonRod's music
    I recently updated to Yosemite and never had this issue before.

    I'm not 100% sure of the ins and outs, but it's some sort of known issue between Yosemite, Airport and wifi. All you can do is wait for a fix and keep restarting your equipment as and when needed, unless you have the ability to connect your Mac via ethernet.

  • Why am I having trouble importing vCards? I follow the Help Center instructions by dragging and dropping, but some don't sync into the cloud. And why can't I drag multiple vCards? I have over 4,000. Please tell me I don't have to do one at a time?

    Why am I having trouble importing vCards? I follow the Help Center instructions by dragging and dropping, but some don't sync into the cloud. And why can't I drag multiple vCards? I have over 4,000. Please tell me I don't have to do one at a time?

    carolinechx wrote:
    i know the description may be a little bit too confusing
    Mostly because you are not using any capital letters or paragraph returns and your post is difficult to read.

  • Why are some of my calendar appointments synching, some synch multiple times and others not at all?

    why are some of my calendar appointments synching, some synch multiple times and others not at all?

    iTunes: May be unable to transfer videos to iPhone, iPad, or iPod - http://support.apple.com/kb/TS1497

  • What is the best way to create shared variable for multiple PXI(Real-Time) to GUI PC?

    What is the best way to create shared variable for multiple Real time (PXI) to GUI PC? I have 16 Nos of PXI system in network and 1 nos of GUI PC. I want to send command to all the PXI system with using single variable from GUI PC(Like Start Data acquisition, Stop data Acquisition) and I also want data from each PXI system to GUI PC display purpose. Can anybody suggest me best performance system configuration. Where to create variable?(Host PC or at  individual PXI system).

    Dear Ravens,
    I want to control real-time application from host(Command from GUI PC to PXI).Host PC should have access to all 16 sets PXI's variable. During communication failure with PXI, Host will stop data display for particular station.
    Ravens Fan wrote:
    Either.  For the best performance, you need to determine what that means.  Is it more important for each PXI machine to have access to the shared variable, or for the host PC to have access to all 16 sets of variables?  If you have slowdown or issue with the network communication, what kinds of problems would it cause for each machine?
    You want to located the shared variable library on whatever machine is more critical.  That is probably each PXI machine, but only you know your application.
    Ravens Fan wrote:
    Either.  For the best performance, you need to determine what that means.  Is it more important for each PXI machine to have access to the shared variable, or for the host PC to have access to all 16 sets of variables?  If you have slowdown or issue with the network communication, what kinds of problems would it cause for each machine?
    You want to located the shared variable library on whatever machine is more critical.  That is probably each PXI machine, but only you know your application.

  • Using same bind variable multiple times in Dynamic sql

    Hi;
    I have a query which uses same variable multiple times, is there a way I could use only one time that variable and it will take multiple times.
    Query is;
    execute immediate 'SELECT count(*) FROM x WHERE MONTH_ID = :VOMNTH_ID
    UNION
    SELECT count(*) FROM Y WHERE MONTH_ID = :VOMNTH_ID
    union
    SELECT count(*) FROM z WHERE MONTH_ID = :VOMNTH_ID ' using month1,month1,month1
    What I want Just supply month1 only once.
    Your help is appreciated.
    VKM

    the way suggested by Nigel worksI'm not sure what you intend to use the resultset for but remember that UNION will remove duplicates from the result set and could possibly sort it too. Even if that were not the case (for example if you used UNION ALL) Oracle does not specifically guarantee the order of resultsets.
    If you are expecting the first row to contain the first count (and so on) then you might not get the answer you are expecting.
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> SELECT 3 n
      2  FROM   dual
      3  UNION
      4  SELECT 2 n
      5  FROM   dual
      6  UNION
      7  SELECT 1 n
      8  FROM   dual;
             N
             1
             2
             3
    SQL> SELECT 1 n
      2  FROM   dual
      3  UNION
      4  SELECT 2 n
      5  FROM   dual
      6  UNION
      7  SELECT 2 n
      8  FROM   dual;
             N
             1
             2
    SQL>

  • Same BI query multiple times, different variable values ...

    Hi all, Im having a problem executing a BI query multiple times, passing different parameters. What I did is drag & drop the query multiple times (from the "Find Data" section) and pass different variable values from the signal-in of the nested iview that contains all of them, everyone has its own chart view. The problem is, only the first occurrence of the query is showing (only the first chart). I dont know if there is a restriction, or if I am missing something.
    Thanks in advance.
    Daniel

    Hi all, forget about this, it was a problem in the query definition not in visual composer. Im closing this thread.
    Regards.
    Daniel

  • Why a getter method of a managed bean WILL be called multiple times

    Why a getter method of a managed bean WILL be called multiple times during the JSF lifecycle?Why this designed?

    This is by design indeed. Each step in the JSF lifecycle can call a getter to get the required information.

  • FocusLost event on same component generated multiple times... why?

    This is a reiteration of the topic of a post from Jan. 2006 by Toxter.
    Although Toxter got his problem resolved, the question of the title of his post (same as mine) was never answered.
    Suppose you want to validate text of a component (say, a JTextField) by checking the text when the component loses focus, by implementing the focusLost method in a FocusListener. The listener catches focusLost events from the given component and does validation and if found invalid, opens a warning dialog (say, a JOptionPane). Suppose further that in your implementation of the focusLost method, after returning from the JOptionPane call, you call requestFocusInWindow() on the JTextField so the user can make the correction straight-away. What happens, weirdly, is that you get multiple recurrences of a focusLost event from the very same textfield component, generating multiple JOptionPane popups, before the user is actually able to access the textfield and make a correction.
    No reason was given as to why this happens. Toxter reported that focusLost would get called twice. I routinely get 3 occurrences.
    In any case, why does this happen?
    There are at least a couple of other workarounds besides the one accepted by Toxter:
    1) you can drop the call to textField.requestFocusInWindow... without that call you don't get multiple occurrences of focusLost FocusEvents
    2) you can wrap the call to requestFocusInWindow in a call to SwingUtilities.invokeLater (within the run method of an anonymous Runnable):
         if( !validatePositiveIntegerField(txtFld) )
             JOptionPane.showMessageDialog(this, INPUT_ERR_MSG,
                      INVALID_ENTRY_TITLE, JOptionPane.WARNING_MESSAGE);
             SwingUtilities.invokeLater(new Runnable()
                public void run()
                   txtFld.requestFocusInWindow();
          }Workarounds are great but it's nice to understand the underlying causes of problems too... If anyone (Toxter, do you know?) can give even just a brief nutshell explanation as to why this occurs, I'd like to hear it.
    Thanks in advance.

    Use an InputVerifier:
    http://forum.java.sun.com/thread.jspa?forumID=57&threa
    dID=776107&start=6Thanks for the reply, camickr. Several workarounds were already noted. That wasn't the question. The question was: what is the underlying cause of the multiple occurrences of focusLost events from the given JTextField which cause the JOptionPane to pop up multiple times? On the face of it, it seems to be a bug in how focus events are getting generated. Here is a bit of code that will generate the problem:
       public void focusLost(FocusEvent e)
          if( e.getSource() == txtFld && !validatePositiveIntegerField(txtFld) )
             JOptionPane.showMessageDialog(this, INPUT_ERR_MSG, INVALID_ENTRY_TITLE,
                                           JOptionPane.WARNING_MESSAGE);
             txtFld.requestFocusInWindow();
       }In my previous post, I pointed out that the multiple focusLost events can be avoided if one either drops the call to txtFld.requestFocusInWindow() altogether, or else wraps that call in the run method of a Runnable executed with SwingUtilities.invokeLater. But the question I posed was, why is the code above causing multiple occurrences of focusLost events from the txtFld component?
    Any help in getting an explanation of that seemingly buggy behavior would be appreciated.
    Cheers

  • Why LOOP AT XVBAP is triggering multiple times in user-exit in 1 item order

    Hi,
    Just curious,
    I put the break point at LOOP AT XVBAP in user-exit of MV45A include of sales order transaction, then I created a sales order with ONLY one item(10) of 1 quantity (meaning, ONLY one schedule line)....then, Why my break-point(LOOP AT XVBAP) is triggering multiple times? even though there is ONLY one item/1 quantity? is supposed to trigger only 1 time(one iteration) right?
    why mupltiple iterations are happening?
    thank you

    Hello ,
    yeah thats true , that exit programs will called several types  by SAP itself , so u need to find right FORM exits for ur requirements.
    regards
    Prabhu

Maybe you are looking for

  • I have 3 of everysong in my itunes.  How do I delete multiple songs?

    I recently transferred my itunes library to a new computer.  Now in itunes I have all my songs, but times 3.  Every song (about 3800 of them) are in my library 3 times.  How can I delete 2 of every song (about 7600 songs).  How do I delete multiple s

  • Question to send a mail

    Hello, I want to send mail with a condition with outlook. I have a folder which contain html's files. And if the html file is number1, i send it to [email protected], if the file is number2, I send it to [email protected] But, how can I do to send ma

  • Dealing with weird versioning

    Hi, I'm making a PKGBUILD for EiffelStudio, a IDE for the Eiffel language. Everything works fine so far, however the versioning scheme and package URL are kind of weird. For example, the current version of the tarball is called "Eiffel66_gpl_82484-li

  • Asset conversion

    Dear Gurus, The business scenario is client send some LCDs as FOC items to its dealer. As per management decision client takes them back. Now question is how to get these assets back to inventories. Depreciation for 7 months has been charged on these

  • Server0 never comes up J2EE down- Urgent!!!!!

    Hi, Ihave installed a SM 4.0 system with ABAP+Java. After all done with SP10, I had changed the master client from 001 to 100 which I created. From then my Server0 is not starting at all. I tried all the below: 1. Created a new client 120, did a clie