How to change Interval in TIMER control?

Source code related resources

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

How to change Interval in TIMER control?

Post by mol »

Hi guys!
can you help me how to change Interval in TIMER control?
I can't find it anywhere...
Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Contact:

Re: How to change Interval in TIMER control?

Post by Paramvir »

Hello

I have found this code in Giovanni's HMG Tutorial:
/*

#include "hmg.ch"

FUNCTION Main()

DEFINE WINDOW Form_1 ;
AT 90,90 ;
WIDTH 250 ;
HEIGHT 150 ;
MAIN
END WINDOW

DEFINE TIMER tempo ;
PARENT Form_1 ;
INTERVAL 1000 ;
ACTION print_clock()

Form_1.Activate

RETURN NIL


FUNCTION print_clock()
Form_1.title := time()
RETURN NIL

*/
perhaps this may help you.

Regards
User avatar
mustafa
Posts: 1162
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: How to change Interval in TIMER control?

Post by mustafa »

Hi Mol

Code: Select all



  DEFINE WINDOW Form_1            ;
	AT 0, 0                   ;
	WIDTH 405 HEIGHT 405      ; 
	TITLE ""                  ;
        MAIN 
        
        ON KEY ESCAPE ACTION  Form_1.Release )

    
        DEFINE TIMER Timer_1 INTERVAL 1000  ACTION (RELEASE MEMORY)
   
        DEFINE TIMER Timer_2 ;
              INTERVAL 100 ;
              ACTION { || thisWindow.Row := 175, thisWindow.Col := 480 }     // <==  Does not let the window move

...  

Regards

Mustafa
edk
Posts: 914
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: How to change Interval in TIMER control?

Post by edk »

Form_1.Timer_1.Value := nInterval //change timer's interval
You can only set new interval, can't read actual value by "Value"

You can read interval by: _HMG_SYSDATA [ 8 ] [ GetControlIndex (ControlName,ParentForm) ] => timer's interval current value

The sample:

Code: Select all

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'Timer Test' ;
		MAIN 

		DEFINE TIMER Timer_1 ;
		INTERVAL 3000 ;
		ACTION TimerTest() 

	END WINDOW

	ACTIVATE WINDOW Form_1

Return

Procedure TimerTest()
	Local nInterval := _HMG_SYSDATA [  8 ] [ GetControlIndex ( 'Timer_1', 'Form_1') ] 	// timer's interval current value

	Form_1.Timer_1.Enabled := .F.
	MsgInfo ('Timer ' + hb_ValToStr ( nInterval / 1000 ) + ' sec.')
	IF nInterval > 1000
		nInterval -= 1000
		Form_1.Timer_1.Value := nInterval		//change timer's interval 
	ENDIF
	Form_1.Timer_1.Enabled := .T.

Return
Post Reply