17 Feb 2017

Timer Example On Web Server Form.
CREATE ONE CONTROL BLOCK HAVING ONE DISPLAY ITEM AND FIVE PUSH BUTTONS.
PROPERTIES OF DISPLAY ITEM
NAME : MY_SCROLL_BAR
DATA TYPE          : CHARACTER
MAX LENGTH     :30
XPOSITION         : 259
YPOSITION          :157
WIDTH                  : 5
HEIGHT                 :12

PUSH BUTTONS  PROPERTIES
NAME                                   : CREATE              STOP     RESET    DELETE  DEFAULT
WIDTH                                 : 113                       113         113         113         0
HEIGHT                               : 20                         20           20           20           0
XPOS                                   : 25                         86           421         464         0
YPOS                                   : 52                         153         153         52           0
Keyboard Navigation           : No                        No          No          No          Yes
Mouse Navigation                : No                        No          No          No          Yes

Trigger on Create Button
DECLARE
                V_TIMER TIMER;
BEGIN
                -- FIND TIMER FIRST IF ALREADY EXISTS.
                V_TIMER := FIND_TIMER('PRGBARTMR');
                IF ID_NULL(V_TIMER) THEN
                -- CREATING TIMER FOR ONE SECOND... ONE SECOND = 1000 MILLISECOND
                V_TIMER := CREATE_TIMER('PRGBARTMR', 1000, REPEAT);
                ELSE
                                MESSAGE('ALREADY EXISTS.');
                END IF;
                -- WILL HANDLE THIS TIMER IN FORM LEVEL WHEN-TIMER-EXPIRED TRIGGER
END;

Trigger On Stop Button
DECLARE
                V_TIMER TIMER;
BEGIN
                -- FIND THE TIMER FIRST
                V_TIMER := FIND_TIMER('PRGBARTMR');
                IF NOT ID_NULL(V_TIMER) THEN
                                -- THIS WILL STOP THE TIMER AFTER ONE MILLISECOND
                                SET_TIMER(V_TIMER, 1, NO_REPEAT);
                END IF;
                -- WILL HANDLE THIS TIMER IN FORM LEVEL WHEN-TIMER-EXPIRED TRIGGER
END;




Trigger On Delete Button
DECLARE
                V_TIMER TIMER;
BEGIN
                -- FIND THE TIMER FIRST
                V_TIMER := FIND_TIMER('PRGBARTMR');
                IF NOT ID_NULL(V_TIMER) THEN
                                -- THIS WILL DELETE THE TIMER
                                DELETE_TIMER(V_TIMER);
                END IF;
END;

Trigger On Reset Button
DECLARE
                V_TIMER TIMER;
BEGIN
                -- FIND THE TIMER FIRST
                V_TIMER := FIND_TIMER('PRGBARTMR');
                IF NOT ID_NULL(V_TIMER) THEN
                                -- THIS WILL RE-START THE TIMER AFTER ONE SECOND
                                SET_TIMER(V_TIMER, 1000, REPEAT);
                ELSE
                                V_TIMER := CREATE_TIMER('PRGBARTMR',1000, REPEAT);
                END IF;
                -- WILL HANDLE THIS TIMER IN FORM LEVEL WHEN-TIMER-EXPIRED TRIGGER
END;

Coding on When Timer Expired
DECLARE
                V_TIMER_NAME VARCHAR2(30);
                V_WIDTH NUMBER;
BEGIN
                -- GET THE TIMER NAME FIRST.. TO KNOW WHICH TIMER HAS EXPIRED.. IF MULTIPLE TIMER ARE RUNNING
  V_TIMER_NAME := GET_APPLICATION_PROPERTY(TIMER_NAME);
  -- CHECK IF THE SAME TIMER WITH CAPITAL LETTERS
  IF V_TIMER_NAME = 'PRGBARTMR' THEN
                 V_WIDTH := GET_ITEM_PROPERTY('BLKTMR.PRGBAR', WIDTH);
                 IF V_WIDTH < 100 THEN
                                  V_WIDTH := V_WIDTH + 5;
                 ELSE
                                  V_WIDTH := 0;
                 END IF;
                 SET_ITEM_PROPERTY('BLKTMR.PRGBAR', WIDTH, V_WIDTH);
                END IF;
END;


No comments:

Post a Comment