CREATE TIMER Example


Example:

 

*
.Define the TIMER objects and other variables
.
TIMERS  
TIMER     (4)BUTTON1  BUTTONRESULT  
FORM      1START    INTEGER   4CURRENT 
INTEGER   4*.Create the Objects.        
CREATE    TIMERS(1),10        
CREATE    TIMERS(2),50        
CREATE    TIMERS(3),80        
CREATE    TIMERS(4),140        
CREATE    BUTTON1=16:17:35:42,"Exit".        
CLOCK     SECONDS,START        
DISPLAY   *P32:5,"Five Second Timer Expired":                  
*P32:7,"Eight Second Timer Expired":                  
*P32:9,"Fourteen Second Timer Expired";*.Activate the Objects.        
ACTIVATE    TIMERS(1),TEXEC1,RESULT        
ACTIVATE    TIMERS(2),TEXEC2,RESULT        
ACTIVATE    TIMERS(3),TEXEC3,RESULT        
ACTIVATE    TIMERS(4),TEXEC4,RESULT        
ACTIVATE    BUTTON1,EXIT,RESULT*.Wait for an Event to Occur.        
LOOP         EVENTWAIT        
REPEAT*.1 Second Timer Expired.TEXEC1        
CLOCK       SECONDS,CURRENT        
SUB         START,CURRENT        
DISPLAY    *P32:3,"Seconds: ",CURRENT        
RETURN*.5 Second Timer Expired.TEXEC2        
DISPLAY    *P30:5,"X";        
RETURN*.Eight Second Timer Expired.TEXEC3        
DISPLAY    *P30:7,"X";        
RETURN*.Fourteen Second Timer Expired.TEXEC4        
DISPLAY    *P30:9,"X";        
RETURN*.Exit Selected.EXIT        
STOP

 

*

 

 

.Define the TIMER objects and other variables

.

 

 

TIMERS

TIMER

(4)

BUTTON1

BUTTON

 

RESULT

FORM

1

START

INTEGER

4

CURRENT

INTEGER

4

*

 

 

.Create the Objects

.

 

 

  

CREATE

TIMERS(1),10

  

CREATE

TIMERS(2),50

  

CREATE

TIMERS(3),80

  

CREATE

TIMERS(4),140

  

CREATE

BUTTON1=16:17:35:42,"Exit"

.

 

 

  

CLOCK

SECONDS,START

  

DISPLAY

*P32:5,"Five Second Timer Expired":

  

  

*P32:7,"Eight Second Timer Expired":

  

  

*P32:9,"Fourteen Second Timer Expired";

*

 

 

.Activate the Objects

.

 

 

  

ACTIVATE

TIMERS(1),TEXEC1,RESULT

  

ACTIVATE

TIMERS(2),TEXEC2,RESULT

  

ACTIVATE

TIMERS(3),TEXEC3,RESULT

  

ACTIVATE

TIMERS(4),TEXEC4,RESULT

  

ACTIVATE

BUTTON1,EXIT,RESULT

*

 

 

.Wait for an Event to Occur

.

 

 

  

LOOP

 

  

  EVENTWAIT

 

  

REPEAT

 

*

 

 

.1 Second Timer Expired

.

 

 

TEXEC1

 

 

  

CLOCK

SECONDS,CURRENT

  

SUB

START,CURRENT

  

DISPLAY

*P32:3,"Seconds: ",CURRENT

  

RETURN

 

*

 

 

.5 Second Timer Expired

.

 

 

TEXEC2

 

 

  

DISPLAY

*P30:5,"X";

  

RETURN

 

*

 

 

.Eight Second Timer Expired

.

 

 

TEXEC3

 

 

  

DISPLAY

*P30:7,"X";

  

RETURN

 

*

 

 

.Fourteen Second Timer Expired

.

 

 

TEXEC4

 

 

  

DISPLAY

*P30:9,"X";

  

RETURN

 

*

 

 

.Exit Selected

.

 

 

EXIT

 

 

  

STOP

 

 

This example creates four TIMER objects. The timers are created with one, five, eight, and fourteen second values respectively. The one second timer displays a count of the seconds of execution. The remaining three timers flash an 'X' on the screen next to the appropriate label as they expire. Upon clicking the EXIT BUTTON, the program terminates.

 

 



PL/B Language Reference CREATE TABCONTROL Example CREATE TREEVIEW Example