iOS Question Documentation and Timers

SFE

Member
Licensed User
Hello

Back with another basic question. First is there some documentation that explains timers? Maybe I am missing the documentation pile.

In VB6 you create a timer, set its interval and when you enable it, it will fire after the preset interval. It will keep firing at that interval until you disable the timer.

In B4X I create a timer and I initialize it and it fires immediately before I enable it. I check in the sub used in the initialization and verify that it was not enabled. I said ok I can work with I will just return from the sub if the timer is not enabled. It then appears to not return to the sub after the preset interval. So, obviously I need someone to explain B4X timers. I am sorry to be asking for help on such a basic topic but I have not found the documentation that explains B4X timers.

Thanks for educating m.

Here is my sample code. It jumps to Sequence70Timer_Tick sub as soon as the timer is initialized. Then it returns back to the enable line. It appears not to fire again.

tmrF70Sequence.Enabled=False
tmrF70Sequence.Initialize(SequenceF70Timer_Tick,2500)
tmrF70Sequence.Enabled=True

Private Sub SequenceF70Timer_Tick
Log("Sequence F70 Timer= " & tmrF70Sequence.Enabled)
If tmrF70Sequence.Enabled=False Then Return
 

aeric

Expert
Licensed User
Longtime User
1. Use [ code ] Your code here [ /code] <-- without the white spaces
2. You use the timer wrong.
3. In B4X IDE, there is a helpful pop up help when you type the keywords.

1679533890427.png

1679534253623.png

1679534122141.png


Clicking the link brings you to https://www.b4x.com/b4i/help/core.html#timer

Here is an example code:

B4X:
Sub Class_Globals
    Private tmrF70Sequence As Timer
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    tmrF70Sequence.Initialize("F70Sequence", 2500)
    'tmrF70Sequence.Enabled = False ' <-- optional because The timer is disabled until the Enabled property is set to true.
End Sub

Sub F70Sequence_Tick
    Log("Sequence F70 Timer= " & tmrF70Sequence.Enabled) ' always true
End Sub

Sub BtnStartTimer_Click
    tmrF70Sequence.Enabled = True
End Sub
 
Last edited:
Upvote 0
Top