Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Nov 14, 2018 10:29 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Using a timer to repeat an operation.
PostPosted: Tue May 31, 2011 4:09 pm 
Offline

Joined: Sat Dec 30, 2006 6:52 pm
Posts: 130
Location: New York City
I have a program I use to shell out and check my CPU temperature. What code would cause this to repeat every 3 seconds (or so)? I can have it "refresh" by pressing a button, but I would like it to do this "refreshing" on its own every few seconds.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using a timer to repeat an operation.
PostPosted: Tue May 31, 2011 6:30 pm 
Offline

Joined: Sat Mar 25, 2006 1:39 pm
Posts: 894
Location: Morgan Hill, CA
Create a timer and set it to multiple mode (mode 2) with a period value of 3000 milliseconds.

In the Timer's Action event, place code to trigger the refresh function. You can click on the button in code with the line:
PushButtion1.Push

_________________
While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using a timer to repeat an operation.
PostPosted: Wed Jun 01, 2011 7:42 am 
Offline
Site Admin
User avatar

Joined: Tue May 06, 2008 1:07 pm
Posts: 1464
Location: NotEvenOnTheMap, CT
No! Not PushButton.Push! Events are not a means for code organization, they are for... well... events. Often user-driven actions. The point of the Push method is to visually simulate a user action, such as demonstrating that a menu item and a button perform the same task. In this scenario, the button would flash every three seconds.

The correct way to handle this is to have both the timer and button fire the same method.

_________________
Thom McGrath - @tekcor
Web Framework Architect, Real Software, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using a timer to repeat an operation.
PostPosted: Wed Jun 01, 2011 12:13 pm 
Offline

Joined: Sat Mar 25, 2006 1:39 pm
Posts: 894
Location: Morgan Hill, CA
Sorry, you're absolutely right. (I don't know what I was thinking when I posted that.)

Having them both call the same method is clearly a better way to go.

_________________
While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using a timer to repeat an operation.
PostPosted: Thu Jun 02, 2011 5:33 am 
Offline

Joined: Sat Dec 30, 2006 6:52 pm
Posts: 130
Location: New York City
So I should set my timer to multiple mode (2), with a period of 3000 and put "Call GetCPUtemp" (if that's the method name) in the Action event? I will try this. Thanks!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group