Wednesday, November 9, 2016

 Digital Clock Timer's Trick  

In the name of Allah, Most Gracious, Most Merciful
Praise be to Allah, blessing and peace be upon our prophet Mohammed, his family and his companions. After that,

     You can not create a digital clock directly in Oracle forms. There is some work around i will show you to display a digital clock by using the timer trickA timer is not an object but it is actually an internal clock you pro-grammatically create. Now, let's define today's task and recognize what can be the solution for to simply perform the task. 

Task Definition:   

       Create a digital clock.    

Task Solution:

      The timer's trick is the only solution for Oracle Form. 
You can create the clock on the master's block or in the tool bar canvas.

Create a Timer:
  1.    Declare a variable of timer data type.
  2.      Initialize a variable with one second number data type.
  3.      Use a CREATE_TIMER built-in with the timer's name, interval and it's status  repeats every one second on timer's expiration.
  4.      Assign the timer's creation built-in to a variable of timer data type. 
  5.  Paste the following code in  WHEN-NEW-FORM-INSTANCE trigger Form-Level:     
   timer_id   Timer;
   one_sec    NUMBER (5) := 1000;   -- 1 second in milliseconds
   timer_id := CREATE_TIMER ('MYTIMER', one_sec, REPEAT);
         Note: We assign one second interval with 1000 millisecond for one_sec variable.
 The user may be not interested  with seconds but only interested in hours and minutes only. Consequently, you can assign an initial value 60000  millisecond (minute ) for one_minute variable with .number  datatype as mentioned earlier.

       Delete a Timer:

       In timer's creation and expiration one second  created, executed in regards to current system date. It repeats itself endlessly. 
  1.  create a non database on your form named e.g. 'DIGITAL_TIME' with a character data type.
  2. Paste the following code in When-Timer-Expired Trigger Form-Level :
        If you want to display the system date and time in the same field correctly, you have to change the data type from character datatype to DATE TIME datatype and change the format mask for date and time. 

       Now, compile, generate and  run the form, if it works then save your form safely

         On the other hand, digital clock has a disadvantage in regards to form's input stability for the blinking of the cursor; it losses item focus. So digital clock in Oracle Forms is not recommended to use it frequently only for a specific purposes.

 Learn more about:

        ·       In-Direct Global Variable Access
   ·     Menu Item Enable/Disable

Hope this helps...

My success only comes from Allah, pls. note your comments and suggestions are great help for me in progress thanks in advance.


M. Faramawy said...

I would be grateful if you attach FMB file.

Neveen Ebrahim Hamdy said...

what for you have got the code? is my explanation not clear ?
what was the problem you face during the implementation ?