switch cases and timers

This is a discussion on switch cases and timers within the C++ Programming forums, part of the General Programming Boards category; Hi all, i'm new to using multiple timers. Im trying to plan a short project. I was wondering if it's ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    11

    Question switch cases and timers

    Hi all, i'm new to using multiple timers. Im trying to plan a short project. I was wondering if it's possible to store a value from one timer into a variable that a second timer would be able to use. The purpose would be to have TIMER_ONE check and redetermine at long intervals the value of var1 and have TIMER_TWO use that value for a different purpose on a short interval. Any ideas or is this possible at all?

    thanks it would look something like this:

    Code:
    switch (nIDEvent)
    {
    case TIMER_ONE:
    
    var1 = 10;
    break;
    
    case TIMER_TWO:
    
    var2 = var1+5;
    break;
    
    }

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    is that an MS-Windows program where the timer functions were set with win32 api SetTimer() function ? If that is correct, then the timer events happen sequentiallly, not concurrently. So yes, the function to work something like you posted

  3. #3
    The N00b That Owns You!
    Join Date
    Jul 2005
    Location
    Canada!
    Posts
    178
    try including windows.h and put sum infon under the case WM_TIMER just a guess tho, im not tht sure how WM_TIMER works. i just know how ton use it to calculate FPS in OpenGL apps :P

    edit: look it up on msdn
    New Function!!!!

    glAddIdol(C+noob);

    The feeling of rusty spoons against my salad fingers is almost ORGASMIC

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    11
    is that an MS-Windows program where the timer functions were set with win32 api SetTimer() function
    Ancient Dragon: yes it is like you said

    im not sure what this means:
    So yes, the function to work something like you posted
    im just not sure how to set it so that the variables dont go out of scope between the two timers...

    thanks again

  5. #5
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,810
    You could use static so that the variables keep there values when they go out of scope.
    Woop?

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    11

    Smile

    yes! that'll do just fine

    thanks so much

    later

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21