Wide Studio Object Reference

| Wide Studio Object Reference |
Wide Studio Home
Up to
  ## Class Name WSDtimer ## Specification of methods ### WSGIappTimer method Form WSDtimer* WSGIappTimer() Function Returns the global instance of the class: WSDtimer. It is an invalid instance which is created by WSDtimer(). Description Parameters None. Return value Returns the instance. Notice This method is a global function. Do not delete the return value. Samples Refer to addTriggerProc(). ### addTriggerProc method Form long addTriggerProc(WStimerProc proc,WSCuchar rate,void* data) Function Executes the specified procedure once after the specified period. Description Parameters
  (in)WStimerProc proc | the address of the function
  (in)WSCuchar rate | the period
  (in)void* data | the value which is passed to the function

These are following values for the period:

WS250MS | 250 ms
WS500MS | 500 ms
WS750MS | 750 ms
WS1000MS | 1000 ms
WS1250MS | 1250 ms
WS1500MS | 1500 ms
WS1750MS | 1750 ms
WS2000MS | 2000 ms
WS2250MS | 2250 ms
WS2500MS | 2500 ms
WS2750MS | 2750 ms
... | ...
WS19750MS | 19750 ms
WS20000MS | 20000 ms

Return value
  Returns the registration ID.
Notice
  The type of the function: WStimerProc is defined as follows:
  typedef void (*WStimerProc)(WSCuchar,void*);
  For example,if the event procedure: sample_event_procedure() is executed by a WSCvbtn instance or something, the trigger procedure: timer_proc() is registered; then it is fired and displays "hello!" after 1 sec.
Samples

      void timer_proc(WSCuchar clock,void* data){
      //This data is the third parameter of addTriggerProc().
        WSCbase* object = (WSCbase*)data;
        object->setProperty(WSNlabelString,"Hello!");
      }
      void sample_event_procedure(WSCbase* object){
        //Register the trigger proc: 1 sec.
        WSDtimer* timer = WSGIappTimer();
        timer->addTriggerProc(timer_proc,WS1000MS,object);
      }

  ### addTimerProc method

  Form
    long addTimerProc(WStimerProc proc,WSCuchar rate,void* data)
  Function
    Fires the specified procedure at every specified cycles.
  Description
  Parameters

    (in)WStimerProc proc | The address of the function
    (in)WSCuchar rate | The cycle
    (in)void* data | The value which is passed to the function

    There are following value for the cycle:

    WS250MS | 250 ms
    WS500MS | 500 ms
    WS750MS | 750 ms
    WS1000MS | 1000 ms
    WS1250MS | 1250 ms
    WS1500MS | 1500 ms
    WS1750MS | 1750 ms
    WS2000MS | 2000 ms
    WS2250MS | 2250 ms
    WS2500MS | 2500 ms
    WS2750MS | 2750 ms
    ... | ...
    WS19750MS | 19750 ms
    WS20000MS | 20000 ms

  Return value
    Registration ID
  Return value
    Returns the registration ID.
  Notice
    The type of the function: WStimerProc is defined as
    typedef void (*WStimerProc)(WSCuchar,void*);
    For example, if the event procedure: sample_event_procedure() is executed by a WSCvbtn instance or some other execution, the timer procedure: timer_proc() is registered; then it is fired and counts up the value at every 1 sec.
  Samples

        void timer_proc(WSCuchar clock,void* data){
        //The clock parameter is counted up at every 250 ms.
        //It is used to see the time.
        //This data is the third parameter of addTimerProc().
        static int cnt = 0;
          cnt++;
          WSCbase* object = (WSCbase*)data;
          object->setProperty(WSNlabelString,cnt);
        }
        void sample_event_procedure(WSCbase* object){
          //Register the timer proc: 1 sec cycle.
          WSDtimer* timer = WSGIappTimer();
          timer->addTriggerProc(timer_proc,WS1000MS,object);
        }

  ### delTriggerProc method

  Form
    void delTriggerProc(long id)
  Function
    Unregisters the procedure by the specified ID which is returned by addTriggerProc().
  Description
  Parameters

    (in)long ID | the registration ID

  Return value
    None
  Notice
    After firing, it ignores input.
  Samples

          long id = WSGIappTimer()->addTriggerProc(timer_proc,WS1000MS,object);
          //The timer ID is used to stop the timer.
          long id = timer->delTriggerProc(id);

  ### delTimerProc method

  Form
    void delTimerProc(long id)
  Function
    Unregisters the procedure by the specified ID which is returned by addTimerProc().
  Description
  Parameters

    (in)long ID | the registration ID

  Return value
    None.
  Notice
    If given an invalid ID,it ignores input.
  Samples

          long id = WSGIappTimer()->addTimerProc(timer_proc,WS1000MS,object);
          //The timer ID is used to stop the timer.
          long id = timer->delTimerProc(id);

  Document Release 3.20
  For use with Wide Studio Release 3.20, Spring 2003

  Wide Studio Home | Up to

  Copyright(C) T. Hirabayashi, 1999-2003 |  | Last modified: February 3, 2003