How to make a timer

Posted By: Redoine

How to make a timer - 02/05/13 21:34

Hello good guys

1) i need a code of a timer
i mean a code that execut a function or action evry second , 2s or anytime u want

2) and also i need to know how to enable and disable a function

3) and i'm looking for a pack of lite c code snippets (no AUMs please)

and if someone could make a lite c code library that will be great (like VB.net code library)

Thank you very much
Posted By: Uhrwerk

Re: How to make a timer - 02/05/13 21:41

1. + 2.
Code:
var enabled = 1;
void my_special_timer_function()
{
    while (1)
    {
        while (!enabled)
            wait(1);
        while (enabled)
        {
            // Do whatever you want to do every second...
            wait(-1)
        }
    }
}

Posted By: Realspawn

Re: How to make a timer - 02/05/13 22:03

http://www.opserver.de/coni_users/web_users/pirvu/au/scripts/aumquestions.zip

there is your code snippets library wink
Posted By: milaz

Re: How to make a timer - 02/05/13 22:03

Originally Posted By: Uhrwerk
1. + 2.
Code:
var enabled = 1;
void my_special_timer_function()
{
    while (1)
    {
        while (!enabled)
            wait(1);
        while (enabled)
        {
            // Do whatever you want to do every second...
            wait(-1)
        }
    }
}



you forgot "wait(1);" for the first while...
Posted By: Redoine

Re: How to make a timer - 02/05/13 22:12

Thank you
Posted By: Uhrwerk

Re: How to make a timer - 02/05/13 22:15

@milaz: I don't get it, sorry. Where is that wait(1) required?
Posted By: Superku

Re: How to make a timer - 02/05/13 22:20

@milaz: while, for and if don't require the { } braces when there is only one instruction that should be included in the according case.
© 2024 lite-C Forums