Tuesday, March 31, 2009

Timer Implimentation steps in forms with example

/*This is regarding the usage of a timer and also the retrieval of data from a record group which contains static values*\
--In New form instance trigger--
DECLARE
timer_id Timer;
one_minute NUMBER(5) := 1000; --in milliseconds (ie:1 second)
BEGIN
timer_id := CREATE_TIMER('emp_trasset', one_minute, REPEAT); --timer created
END;

/* This is applied on an item to run surrounding the canvas */
--in when timer expired trigger--
declare
v varchar2(25);
x number;
y number;
begin
/*to get the name of the timer expired . Applicable in case of more than one timers are used*/
v:=get_application_property(timer_name);
--to get time updated in every second & display it in a text item
:TIME:=TO_char(SYSDATE,'HH:MI:SS AM');
--to get the x,y positions
x:=get_item_property('TEST_TEXT',x_pos);
y:=get_item_property('TEST_TEXT',y_pos);
--To retrieve the nth row from the given column
:TEST_TEXT := Get_Group_CHAR_Cell( 'record_group.column_name','nth row to be retrieved');
--Check and set the position within the limit eg:10 to 300 here
if x=10 and y<300 then
x:=10;
y:=y+10;
elsif y=300 and x<300 then
x:=x+10;
y:=300;
elsif x=300 and y<=300 and y>10 then
x:=300;
y:=y-10;
elsif y=10 and x<=300 then
x:=x-10;
y:=10;
else
x:=10;
y:=10;
--set the position of item so that a moving effect is obtained.
end if;
set_item_property('TEST_TEXT',x_pos,x);
set_item_property('TEST_TEXT',y_pos,y);
end;

No comments:

Post a Comment