Home » Developer & Programmer » Forms » timer expired example
timer expired example [message #274728] Wed, 17 October 2007 00:46 Go to next message
roni_a180
Messages: 45
Registered: October 2007
Member
hi

i have two text field, 1st is roni and 2nd is ahmed, i want to see when the form is open 1st five minutes display roni and next 5 min display ahmed automatically. and this display sequence running until the form closed

thx
roni
Re: timer expired example [message #274736 is a reply to message #274728] Wed, 17 October 2007 01:05 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search this forum for 'timer' or go to the reference manual which you can get from the 'documentation' link on the Oracle Forms website.

David
Re: timer expired example [message #274755 is a reply to message #274736] Wed, 17 October 2007 01:28 Go to previous messageGo to next message
roni_a180
Messages: 45
Registered: October 2007
Member
give me some web site address

where r found this related documentation
Re: timer expired example - sample code [message #274811 is a reply to message #274755] Wed, 17 October 2007 04:34 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Say please. Wink

Source #1 would be Forms help. Open Forms builder and hit F1. There are examples of almost every built in in the help files. Then there's OTN (otn.oracle.com), Oracle's technical website. If you still have problems you come here or go to another forum like the OTN forums (forums.oracle.com) and you search for other threads about the same problem you have. If you cannot find any however, you can post a question. But I'm afraid that David is right. There should be examples of timers on the board.

Anyway, I've attached a small sample .fmb file. It does what you asked for: it switches two text items on the canvas. The third text item allows you to change the interval from 1 to 15 seconds. No guarantees though, it was made using Oracle Forms 10g (so 9i or earlier won't work, I'm afraid) and it has NOT been tested thouroughly. It gives you a slight idea how you could proceed.

Here's how the form can be created:
  1. Create a control block CONTROL. Make it single record
  2. Create two text items: SPIDERMAN and SUPERMAN. Both are disabled. Give them a different initial value.
  3. Set the visible property of SPIDERMAN to FALSE.
  4. Create a text item "INTERVAL": numeric, range 1 to 15, format mask "99". The initial value is set to 5
  5. Create a button "BT_EXIT" to neatly close the form.
  6. Create a basic form layout (layout wizard):
    • make SPIDERMAN and SUPERMAN the same size
    • place SPIDERMAN and SUPERMAN on top of each other
    • place INTERVAL and BT_EXIT as you see fit
  7. Create a WHEN-NEW-FORM-INSTANCE trigger with the following code:
    Declare
    	v_timer TIMER;
    Begin
    	v_timer := Create_Timer('MYTIMER', :CONTROL.INTERVAL*1000, REPEAT);
    End;
  8. Create a WHEN-TIMER-EXPIRED trigger with the following code:
    Declare
    	v_timer TIMER;
    Begin
    	v_timer := Find_Timer('MYTIMER');
    	
    	If NOT ID_NULL(v_timer) Then
    		IF get_item_property('CONTROL.SUPERMAN', Visible) = 'TRUE' THEN
    			set_item_property('CONTROL.SUPERMAN', Visible, Property_False);
    			set_item_property('CONTROL.SPIDERMAN', Visible, Property_True);
    		ELSE
    			set_item_property('CONTROL.SUPERMAN', Visible, Property_True);
    			set_item_property('CONTROL.SPIDERMAN', Visible, Property_False);
    		END IF;
    	End If;
    End;
  9. Create a WHEN-VALIDATE-ITEM trigger on CONTROL.INTERVAL with the following code
    Declare
    	v_timer TIMER;
    Begin
    	v_timer := Find_Timer('MYTIMER');
    	
    	If NOT ID_NULL(v_timer) Then	
    		Delete_Timer('MYTIMER');
    	End If;
    	
    	v_timer := Create_Timer('MYTIMER', :CONTROL.INTERVAL*1000, REPEAT);
    End;
  10. Create a WHEN-BUTTON-PRESSED trigger on CONTROL.BT_EXIT with the following code:
    Begin
    	Exit_Form(NO_VALIDATE);
    End;
When you run the form you should see that SPIDERMAN and SUPERMAN are visible in turn. The cycle is default set to 5 seconds. You can change that by setting a different value in the INTERVAL item.

This should give you an idea of the working of a timer. Note the use of the Delete_Timer built-in.

MHE
  • Attachment: timertest.fmb
    (Size: 60.00KB, Downloaded 2823 times)

[Updated on: Wed, 17 October 2007 04:35]

Report message to a moderator

Re: timer expired example [message #334836 is a reply to message #274755] Fri, 18 July 2008 05:32 Go to previous messageGo to next message
astaputra
Messages: 11
Registered: July 2008
Junior Member
Hi Maahir,
Very good example. But my case is different. I will explain my scenario. I have one Order LOV for one text box. When ever i select any value, then it has to show all the related items for that particular Order. Like wise when i select other order no then for that particular order no, i need to show items. For that i need to use timer, because i cant use go_block in when validate item. I just kept the create timer in when validate item also. but it is not working properly.

Can you please explain me how to use the timer for my scenario.

I applied your logic, but when ever form opens it is firing(as i wrote in when new form instance), but i tried to keep the same code in when validate item also but it is not working, may be some code i am missing.

I would be grateful to you.

Regards,
Akash.
Re: timer expired example [message #335077 is a reply to message #334836] Sun, 20 July 2008 19:31 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

You want to defy forms restriction of go_block thru timer? then, at when-validate-item you must create a timer, no_repeat, interval is one(1) miliseconds. On block's when-timer-expired put your go_block code.
Re: timer expired example [message #335360 is a reply to message #335077] Mon, 21 July 2008 23:40 Go to previous messageGo to next message
astaputra
Messages: 11
Registered: July 2008
Junior Member
Thanks Wency sorry for late reply bcs i am on leave. I will update you soon after using your suggestion.

Thanks
Re: timer expired example [message #335480 is a reply to message #335077] Tue, 22 July 2008 05:10 Go to previous messageGo to next message
astaputra
Messages: 11
Registered: July 2008
Junior Member
Hi Weency,
one small doubt. As you said i wrote code for Create Timer in When validate item and at form level i created timer expired trigger and wrote go block functionality. But how to fire the timer trigger. can i put both creation and firing the timer in when validate item. If yes what is the code for firing the timer trigger.

Please guide me how to proceed further. I followed the Mee example. it works fine. After changing to when validate item then it is not working. Little bit confused.

Please help me out in this issue.

Thanks
Re: timer expired example [message #335592 is a reply to message #335480] Tue, 22 July 2008 20:30 Go to previous message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

The interval is 1 milisecods, so after the when-validate fires the when-timer-expires will fires automatically.
On when-validate just create the timer. How to fire? input any on that item where you put when-validate-item trigger with create timer code then press tab key.
Previous Topic: DEFAULT_WHERE
Next Topic: Form Update
Goto Forum:
  


Current Time: Fri Apr 26 11:06:50 CDT 2024