Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter NineDialog Functions (continued)

DialogSetTimer Function

Overview

The DialogSetTimer function sets a repeating timer which results in periodic calls to the dialog timer procedure for the current dialog page.

Syntax/Parameters

Syntax

int = DialogSetTimer ( int interval, [int id] );

Parameters

interval

An int specifying the time-out in milliseconds between timer events. A value of less than 10ms will be set to 10ms.

id

An optional int specifying a timer id. The id is passed to the timer procedures. If omitted, the id is set to zero.

Return Value

Returns an int value as ERROR_NONE or a formatted error code. Use the GetLastError function to retrieve error information.

Remarks

A script can create timers by using the DialogSetTimer function. A new timer starts timing the interval as soon as it is created. A script can change a timer's time-out value by using DialogSetTimer and can stop a timer by using the DialogKillTimer function. To use system resources efficiently, applications should destroy timers that are no longer necessary.

The time interval can be changed by calling DialogSetTimer with the same id and a new interval.

After the expiration of the timer, “timer” procedure to be called with the id of the timer that expired. The timer will repeat the event on each cycle until the DialogKillTimer is called or the dialog page is closed.

Example

    int         count;
    DialogBox("TimerTestDlg", "foo_");
    exit;


int foo_load() {
    count = 10;
    DialogSetTimer(1000, 1);
    return 0;
    }
        
int foo_action(int id, int code) {
    if (id == 102) {
      DialogKillTimer(1);
      EditSetText(101, "Stopped!");
      }
    return 0;
    }

int foo_timer(int id) {
    count--;
    if (count == 0) {
      DialogKillTimer(1);
      DialogPostOK();
      return ERROR_NONE;
      }
    EditSetText(101, FormatString("Dialog will close in %d seconds", count));
    return 0;
    }
        

#resource

TimerTestDlg DIALOG 0, 0, 150, 30
EXSTYLE WS_EX_DLGMODALFRAME
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Timer Test"
FONT 8, "MS Sans Serif"
{
 CONTROL "", 101, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 6, 10, 100, 8, 0
 CONTROL "Stop", 102, "button", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_TABSTOP, 110, 7, 30, 14, 0
 }

#endresource

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic