Creating, Stopping, Re-Starting and Deleting a Timer in Oracle Forms
2016-12-25 18:10
4179 查看
[align=justify]I have written many posts previously on Timers in Oracle Forms like how to change images randomly with timers and how to display a clock using timer, but in this post I am simply describing to how to create a timer, stop a timer, re-start a timer and deleting a timer.[/align] [align=justify] [/align] [align=justify]The following is the screen shot for this example showing a progress bar based on a display item:[/align] [align=justify] [/align]
[align=justify] [/align] [align=justify]You can also download this form from the following link Timer.fmb[/align] [align=justify] [/align] [align=justify]Create a display item with the following properties:[/align] [align=justify] [/align] [align=justify]Name: Prgbar[/align] [align=justify]Width: 5[/align] [align=justify]Bevel: Plain[/align] [align=justify]Background Color: blue[/align] [align=justify] [/align] [align=justify]Write the following code for the "Create Timer" button:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Stop Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Re-Start Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Delete Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
Then finally write the code for When-Timer-Expired trigger at form level to handle the timer and to do specific task:
[align=justify]When-Timer-Expired trigger[/align] [align=left] 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;
-- will handle this timer in form level when-timer-expired trigger
End;[/align]
[align=justify] [/align] [align=justify]You can also download this form from the following link Timer.fmb[/align] [align=justify] [/align] [align=justify]Create a display item with the following properties:[/align] [align=justify] [/align] [align=justify]Name: Prgbar[/align] [align=justify]Width: 5[/align] [align=justify]Bevel: Plain[/align] [align=justify]Background Color: blue[/align] [align=justify] [/align] [align=justify]Write the following code for the "Create Timer" button:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Stop Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Re-Start Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
[align=justify]Write the following code for the "Delete Timer" buton:
[/align] [align=justify]When-Button-Pressed trigger[/align] [align=left] 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;[/align]
Then finally write the code for When-Timer-Expired trigger at form level to handle the timer and to do specific task:
[align=justify]When-Timer-Expired trigger[/align] [align=left] 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;
-- will handle this timer in form level when-timer-expired trigger
End;[/align]
相关文章推荐
- Starting and Stopping Oracle Fusion Middleware
- Displaying Tabbed and Stacked Canvas Using Show_View In Oracle Forms
- Creating and Deleting Custom Menus in Visio
- Map Columns From Different Tables and Create Insert and Update Statements in Oracle Forms
- Creating and deleting threads dynamically in eCos
- Determining Current Block and Current Item in Oracle Forms
- Using Find_Alert and Show_Alert in Oracle Forms
- Populate A List Item With Record Group In Oracle Forms Using Populate_List And Create_Group_From_Query Command
- Know How And When To Use System.Message_Level To Control Messages In Oracle Forms
- Creating the Same Program in Windows Forms and WPF
- Populate A List Item With Record Group In Oracle Forms Using Populate_List And Create_Group_From_Query Command
- Create Timer Example To Show Image Presentation in Oracle Forms
- Creating Timer in Oracle D2k / Forms 6i and Displaying a Clock
- 二、Starting and Stopping Systems in SAP HANA Studio
- An Example of Pre-Query and Post-Query Triggers in Oracle Forms With Using Display_Item to Highlight Dynamically
- Set Font Properties On Mouse Hover Of Push Button And Text Items At Run time In Oracle Forms
- Creating Excel File in Oracle Forms
- Using Single Alert For Messages And Confirmation Messages In Oracle Forms With Set_Alert_Button_Property
- R12.2——Starting & Stopping Admin and Managed server in FMW
- Creating Custom Login Screen In Oracle Forms 10g