Page 1 of 1 1
Topic Options
#87417 - 2002-08-23 03:51 AM Timer in kixforms
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
Could someone explain what the Timer object is used for in kixforms? I'm guessing it's instead of using loops.

If that's the case, i'm wondering what makes it better than loops.

Top
#87418 - 2002-08-23 03:56 AM Re: Timer in kixforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
haven't tried it but quess it goes into same category with IE timer.

and it is in some situations best way to schedule things.
not looping, but setting the time for thing to happend.
_________________________
!

download KiXnet

Top
#87419 - 2002-08-23 04:18 AM Re: Timer in kixforms
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
I see, what confused me was the 'interval' part in the object. It sounded like looping.
Top
#87420 - 2002-08-23 05:30 AM Re: Timer in kixforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it can be set as loop, sure...
so I don't think there is misunderstanding.

anyway, shawn is the best guide on this.
my last post did not come from trying these things with forms, but just from the thought of forms being a link to windows api...

I've also been confused by that with some IE scripting. so, welcome to the club.

good night, or whatever is the time in there.
my clock says:
06:30

and postcount says:
3000, rest a while man----->

regards to you all my fellows and try to code happily ever after.
_________________________
!

download KiXnet

Top
#87421 - 2002-08-23 11:19 AM Re: Timer in kixforms
Borte Offline
Fresh Scripter

Registered: 2002-08-20
Posts: 29
Loc: Europe / Norway
The timer object is used to perform a task at an specified time interval.

Example:
If you set the timer to an interval of 1000 then the timer event (OnTimer) will be executed every second. If you set it to 60000 then the timer will be executed every minute and so on...

I have used this to show timed dialog boxes to the user. When the timer is trigged the dialog boxe wil close just like the timeout value on the MessageBox() function.

Here is how i used it in my code:

code:
$tmrTimer          = $Form.Timer()
$tmrTimer.InterVal = 20000 ;20 seconds / time is given in milliseconds
$tmrTimer.OnTimer = "tmrTimer_OnTimer()"

Function tmrTimer_OnTimer()
$Form.Hide
EndFunction

I hope this explains some of it..

Top
#87422 - 2002-08-23 02:42 PM Re: Timer in kixforms
punkie Offline
Getting the hang of it

Registered: 2002-06-23
Posts: 67
Hehe you're on the same time line as me Lonkero.
It sounds pretty useful to me [Smile] Have to check that code out.

Top
#87423 - 2002-08-23 03:52 PM Re: Timer in kixforms
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Here's some code that takes advantage of the timer...

code:
; popup.kix

Break On

$Form = CreateObject("Kixtart.Form")

$Form.BackColor = &00D0FFFF
$Form.BorderStyle = 0 ; None
$Form.ClientHeight = 1665/15 ; pixels = twips / 15
$Form.ClientLeft = 8580/15
$Form.ClientTop = 11745/15
$Form.ClientWidth = 2775/15
$Form.ScaleHeight = 1665/15
$Form.ScaleWidth = 2775/15
$Form.ShowInTaskbar = False ; Not ready yet !

$Label = $Form.Label
$Label.Alignment = 2 ; Center
$Label.Appearance = 0 ; Flat
$Label.Caption = "Wasabi?"
$Label.ForeColor = &80000008
$Label.Height = 195/15
$Label.Left = 480/15
$Label.Top = 660/15
$Label.Width = 1695/15

$Timer = $Form.Timer(500) ; 500 msecs
$Timer.OnTimer = "Timer_Timer()"
;$Timer.Show

$Form.ForeColor = &00C00000
$Form.Line(2760/15,0,2760/15,1680/15)
$Form.Line(0,0,0,1680/15)
$Form.Line(0,0,2760/15,0)

; Move it below the visible screen (and a little just in case)

$Form.Top = $Form.Screen.Height + 10

; Move it to the far right of the visible screen (minus a little, just for esthetics)

$Form.Top = $Form.Screen.Width - ($Form.Width + 10)

; We're gonna move it up

$DirectionIsUp = 1

$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents)
Loop

Exit 1

Function Timer_Timer()

; Move at 10 millisecond intervals (100 times a second, 3 times what the eye can see)

$Timer.Interval = 10

; If it's moving up

If $DirectionIsUp

; Move it up 3 pixels every 10 milliseconds

$Form.Top = $Form.Top - 3

; Move until the whole form is shown

If ($Form.Bottom < $Form.Screen.Height)

; This specifies how long it will stay shown (Unmoving)

$Timer.Interval = 3000

; We're gonna move it down next...

$DirectionIsUp = 0

EndIf

Else

; Move it down 3 pixels every 10 milliseconds

$Form.Top = $Form.Top + 3

; Move until the whole form is shown (plus 10 twips to make sure it's hidden)

If $Form.Top >= $Form.Screen.Height

$Timer.Enabled = 0

$Form.Hide

EndIf

EndIf

EndFunction


Top
#87424 - 2002-08-23 05:37 PM Re: Timer in kixforms
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Jooel -

Congratulations on joining the 3000-post club! You are a great source of information and help.
_________________________
Dean

Top
#87425 - 2002-08-26 11:13 AM Re: Timer in kixforms
Schuliebug Offline
Hey THIS is FUN
*****

Registered: 2002-01-18
Posts: 379
Loc: Netherlands
Nice timer function !!
_________________________
Kind regards,

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 323 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.057 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org