Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extend the interval limit of a timer control 3

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
is there a way to extend the interval limit of a timer control? i want to extend the limit above 65,535ms, is it possible?

tia [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 

Take a look at wgcs's post in thread1254-1125261. Is it what you need?
 
ma'am stella,
am sorry but no. the control is kicking in but i just wanted to have a bigger interval in between event firing.

sir mike,
well, this is according to the vfp6's help index.


kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 

Kilroy,

You're right, but the limit was raised in VFP 7.0. From the Help for 7.0 (and above):

[quote
The interval can be between 0 and 2,147,483,647, inclusive, which means that the longest interval is about 596.5 hours (over 24 days).
[/quote]

Can you have the timer fire at a shorter interval, but use a custom property to keep track of the elapsed time? In other words:

- Set the custom property to 0.

- Fire the timer once per minute.

- Each time the timer fires, add 1 to to the property.

- When the property reaches, say, 60, do whatever you need to do, then reset it to 0.

That way, you'll be able to perform the required action once per hour (in this example).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
sir mike,
thank you for your replies. unfortunately, i only have vfp6 installed on my home pc. but nevertheless, i'll still try your suggestion when i get home and see what comes up.

thanks again. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Can you have the timer fire at a shorter interval, but use a custom property to keep track of the elapsed time?
...
- Each time the timer fires, add 1 to to the property.
..

or, as I suggested in the other thread, store the current time ( using SECONDS()..or maybe (60*60*24*day() + Seconds()) ) when the process first starts, and just check the current time against the stored time each time the timer fires... Run your process again (and re-store the current time) if sufficient time has elapsed.

This way dropped events (due to other processes having the processor's attention) won't result in the "right moment" being missed, and won't affect a continuous adding of 1.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Good points, Geoff.

The across midnight thing was why I mentioned perhaps using 60*60*24*day() + Seconds().. but then the problem is the month boundary. Using Day-of-year shifts the problem to once/year. Perhaps simply use a julian date number, but then significant digits might become a problem.

Hey, maybe using DATETIME() is just the thing? Then the only problem becomes Daylight savings. To solve this, we could create a date-time using DATETIME(y,m,d,h,min,sec) from GMT gotten from the system. The one trouble is that this only gives resolution to 1 second.

If someone could figure out the 64-bit arithmatic in VFP, then we could simply convert the SystemTime to a FileTime and have resolution to 100ms.

Code:
* This has resolution to 1 second:
ltMarker = GetGMTasDT()
inkey(2)
ltMarker2 = GetGMTasDT()
WAIT WINDOW ltMarker2-ltMarker

* An alternative that needs some work, but potentially has resolution to 100ms:
l64Marker = GetGMTasFT()
INKEY(2)
l64Marker2 = GetGMTasFT()

lnDiff = Subtract64BitStructures( l64Marker2, l64Marker )
WAIT WINDOW lnDiff

FUNCTION GetGMTasDT()
    DECLARE INTEGER GetSystemTime IN WIN32API ;
        STRING @ LPSYSTEMTIME_lpSystemTime

    lpSYSTIME = REPLICATE(CHR(0),8*2)
    GetSystemTime( @lpSysTime )
    nYear   = Buf2Word( SUBSTR( m.lpSysTime, 1, 2 ) )
    nMonth  = Buf2Word( SUBSTR( m.lpSysTime, 3, 2 ) )
    nDay    = Buf2Word( SUBSTR( m.lpSysTime, 7, 2 ) )
    nHour   = Buf2Word( SUBSTR( m.lpSysTime, 9, 2 ) )
    nMinute = Buf2Word( SUBSTR( m.lpSysTime, 11, 2 ) )
    nSec    = Buf2Word( SUBSTR( m.lpSysTime, 13, 2 ) )
    nThou   = Buf2Word( SUBSTR( m.lpSysTime, 15, 2 ) )
    
    RETURN DATETIME( nYear, nMonth, nDay, nHour, nMinute, nSec )
ENDFUNC

FUNCTION buf2word (lcBuffer) 
  RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ; 
         Asc(SUBSTR(lcBuffer, 2,1)) * 256 
ENDFUNC  


* The FILETIME structure is a 64-bit value representing the number 
*  of 100-nanosecond intervals since January 1, 1601 (UTC).  
*, So, perhaps:

FUNCTION GetGMTasFT()
    DECLARE INTEGER GetSystemTime IN WIN32API ;
        STRING @ LPSYSTEMTIME_lpSystemTime
    DECLARE INTEGER SystemTimeToFileTime IN kernel32;
        STRING  lpSYSTEMTIME,;
        STRING  @ FILETIME

    lpSYSTIME = REPLICATE(CHR(0),8*2)
    GetSystemTime( @lpSysTime )
    lcBuffTime = REPLICATE(CHR(0),8)
    SystemTimeToFileTime(m.lpSYSTIME,@lcBuffTime)
    
    * This would let you manipulate lnBuffTime as a number,
    *   but VFP can't handle numbers this big!!
    * lnBuffTime = BufTo64Bit( lcBuffTime )
    RETURN lcBuffTime
ENDFUNC

* This doesn't work because VFP doesn't support enough places of precision:
*!*	FUNCTION BufTo64Bit (lcBuffer) 
*!*	RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;  
*!*	       Asc(SUBSTR(lcBuffer, 2,1)) * 2^8 +;  
*!*	       Asc(SUBSTR(lcBuffer, 3,1)) * 2^16 +;  
*!*	       Asc(SUBSTR(lcBuffer, 4,1)) * 2^24 +;  
*!*	       Asc(SUBSTR(lcBuffer, 5,1)) * 2^32 +;
*!*	       Asc(SUBSTR(lcBuffer, 6,1)) * 2^40 +; 
*!*	       Asc(SUBSTR(lcBuffer, 7,1)) * 2^48 +;
*!*	       Asc(SUBSTR(lcBuffer, 8,1)) * 2^56
*!*	ENDFUNC  

FUNCTION Subtract64BitStructures( tc64_1, tc64_2 )
  * Well, could someone figure out how to do 64-bit arithmatic in VFP?
  * In VB, the recommendation is to store the value in a Currency type,
  *    which is a 64-bit integer with an implied 4 decimal places.
  *    This works in VB, if you multiply by 10000 before displaying the value.
  * But can we do 64-bit in VFP?
  RETURN 0
ENDFUNC

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Yeah, it appears so!

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
BTW: I don't expect to actually go through all the above WinApi stuff just for a periodic timer, but I wanted to post it here for the record, in case anyone needs to get daylight-savings-safe time stamps.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
apologies if i only replied just now. 'been busy lately. anyways, excellent suggestions you guys have! the effort in replying to my query is already worth a star for each of you. again thank you for the knowledge you've imparted. you guys (and gals) are great!

btw, i went with sir mike's suggestion of using a counter per minute.

peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top