1. ## Clock Function

Can someone help me out? I need some sort of function that will clock the amount of time that it takes to execute my driver script--start to finish, then logs a message to the logviewer, as well as write to a log file.

2. ## Re: Clock Function

You can use function Timer -- it returns amount of seconds passed from the midnight.

</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">q1 = Timer
&lt;here call your_sub&gt;
if q1 &gt; Timer then
'if it passed through midnight
q1 = Timer + 24*60*60 - q1
else
q1 = Timer - q1
end if</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">After this q1 will contain number of seconds that passed while your_sub was executing.

3. ## Re: Clock Function

StartTimer and StopTimer as well as Timer will be useful. Download the SQABasic Reference manual suggested in your previous post. In this manual there's a list of all Robot commands sorted into functional categories starting on page 5.

4. ## Re: Clock Function

Thanks so much, yes, I have already downloaded the reference manual, it is helpful, but sometimes doesn't contain detailed info on trying to accomplish what I want to do. Thanks for the sample code!!! You both have been VERY helpful!

5. ## Re: Clock Function

What is the error that you are receiving?

6. ## Re: Clock Function

denisk, I'm receiving an error on this line:
q1 = Timer + 24*60*60 - q1

Should there be braces around something?

7. ## Re: Clock Function

I'm now not receive an error message. However, how do I convert the time into minutes and seconds? I receiving the following time: 41231.93

8. ## Re: Clock Function

Divide it by 60 -- you will get minutes (the rest from division is seconds)
then divide minutes by 60 again -- you will get hours (the rest from division is minutes)
Then divide hours by 24 -- you will get days (the rest is hours)
then you can divide by 365 -- years; and then by 100 -- centuries;

9. ## Re: Clock Function

Thanks, I see what you mean, however, can you tell me where in the script that you provided to divide by 60, etc.?

10. ## Re: Clock Function

qHour = int(q1/3600)
qMin = int((q1 - (qHour * 3600)) / 60)
qSec = int(q1 - (qHour * 3600) - (qMin * 60))
String qTime = qHour & ":" & qMin & ":" & qSec

I didn't check that, but that's the general idea. A good place to learn more about programming would be a Visual Basic course since Robot is a subset of VB. You could make that all a lot simpler by using the Mod operator.

qMin = (q1 Mod 60)
qSec = (q1 Mod 3600)

However, I haven't used that in awhile so the exact syntax is left up to you.

[ 02-22-2005, 10:12 AM: Message edited by: cyblue ]

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.