What could be causing my destinationVariable to not update in my timer program?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
angelspikes
Messages
10
Reaction score
0
I've debugged and run my program without seeing any results from my "destinationVariable".
What could be wrong?

sub main()

call myfunction()

end sub

sub myfunction()

static myClock As Single

myClock = timer

if (timer - myClock) > 100 Then
destinationVariable += 1 // This variable is linked to this script
End If

End Sub

// I want the function to run in a loop, but I guess I don't need to use the do loop function to make that happen?
 
Physics news on Phys.org
angelspikes said:
myClock = timer
if (timer - myClock) > 100 Then

Since these lines execute right after each other, I doubt that the "if" test will ever be true unless the program gets interrupted between the two statements. That would be "rare". It may happen occasionally if you put this in a hard loop and run it continuously, but the odds on anyone run are very small.