Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

11.4.1 Updating the Timer Event Procedure

As noted above, the COBOL intrinsic function currently being used to retrieve the time retrieves other valuable information, including the current date and day of the week.

Bring up the event procedure code for the timer event in the PowerCOBOL editor. You can do this in the form editor by right clicking on the timer control and selecting Edit the event procedure and then selecting Timer.

Modify the event procedure as follows:

 ENVIRONMENT     DIVISION.
 DATA            DIVISION.
 WORKING-STORAGE SECTION.
 01 Display-Time.
    03 DT-HH      Pic 99.
    03 Filler     Pic X Value ":".
    03 DT-MM      Pic 99.
    03 Filler     Pic X Value ":".
    03 DT-SS      Pic 99.
    
 01 Display-Date.
    03 DD-MM      Pic 99.
    03 Filler     Pic X Value "/".
    03 DD-DD      Pic 99.
    03 Filler     Pic X Value "/".
    03 DD-YY      Pic 9(4).
    
 01 Intrinsic-Date.
    03 New-Date   Pic 9(8) Value Zeroes.
    03 New-Time   Pic 9(8) Value Zeroes.
    03 Filler     Pic X(5).
  
 01 Days-Of-Week.
    03 Filler Pic X(9) Value "Monday".
    03 Filler Pic X(9) Value "Tuesday".
    03 Filler Pic X(9) Value "Wednesday".
    03 Filler Pic X(9) Value "Thursday".
    03 Filler Pic X(9) Value "Friday". 
    03 Filler Pic X(9) Value "Saturday".
    03 Filler Pic X(9) Value "Sunday".
    
 01 Months-Of-Year.
    03 Filler Pic X(9) Value "January".
    03 Filler Pic X(9) Value "February".
    03 Filler Pic X(9) Value "March".
    03 Filler Pic X(9) Value "April".
    03 Filler Pic X(9) Value "May".
    03 Filler Pic X(9) Value "June".
    03 Filler Pic X(9) Value "July".
    03 Filler Pic X(9) Value "August".
    03 Filler Pic X(9) Value "September".
    03 Filler Pic X(9) Value "October".
    03 Filler Pic X(9) Value "November".
    03 Filler Pic X(9) Value "December".
    
 01 Current-Day-Of-Week Pic 9.
 01 Day-Offset          Pic 99.
 01 Month-Offset        Pic 999.
 01 Old-Date            Pic 9(8) Value Zeroes.
 
 01 Date-String  Pic X(30).
  	  
 PROCEDURE DIVISION.
     Move Function Current-Date To Intrinsic-Date.
     If Old-Date Not Equal New-Date
       Move New-Date(1:4) To DD-YY
       Move New-Date(5:2) To DD-MM
       Move New-Date(7:2) To DD-DD
       Move Spaces to Date-String
       Accept Current-Day-Of-Week From Day-Of-Week
       Compute Day-Offset   = (Current-Day-Of-Week * 9) - 8
       Compute Month-Offset = (DD-MM * 9) - 8
       String  Days-Of-Week(Day-Offset:9)      Delimited By Space
               ", "                            Delimited By Size
               Months-Of-Year(Month-Offset:9)  Delimited By Space
               " "
               DD-DD                           Delimited By Size
               ", "
               DD-YY                           Delimited By Size
         Into Date-String
       Move Date-String to "Caption" of DateBox
       Move New-Date To Old-Date
     End-If.
     Move New-Time(1:2) To DT-HH
     Move New-Time(3:2) To DT-MM.
     Move New-Time(5:2) To DT-SS.
     Move Display-Time To "Caption" OF TimeBox.

Save the event procedure code you've just entered and exit the form editor. In order to quickly test the control, change the MyClock module's File Type property to "0 - Execute Module".

Save the project and re-build it. Execute the MyClock module.

The control should now appear as follows with the exception of the actual date and time from your system:

Figure 11.17 The clock control after enhancements.

You may now exit the control, go back to the project manager and change the File Type property for the module back to "1 - DLL Module". Rebuild the project.

You now have a fully functional date and clock control that may be plugged into to any ActiveX enabled application.