PDA

View Full Version : PAUSE for a variable time? Using MAX and MIN



Gerald
- 29th June 2023, 14:20
In my program I have LC as a variable word ranging from 0 to 57000. It is the mainloop counter

In a subroutine I want to pause a variable amount of time in the 0 to 5000 part of the mainloop counts. I have tried to use:

pause 0 min 5000-LC

in other words, if LC is 5000 to 57000 don't pause at all. and between 0 and 5000, pause for a proportional length of time.

I think my pause pause and min statement is missing some syntax?

Any hints please?

Ioannis
- 29th June 2023, 19:33
5000-57000 will give negative number

Maybe you want to use ABS(5000-LC)

so:



a=abs(5000-LC)
a=a min 5000
Pause a


might help?

But then I am not very sure about the maths to calculate the needed delay.

Ioannis

HenrikOlsson
- 30th June 2023, 05:46
Does this provide the functionality you want?


IF LC < 5000 THEN
PAUSE (5000 - LC)
ENDIF

Gerald
- 30th June 2023, 07:05
Thank you Ioannis and Henrik, both your suggestions would be suitable for me. I apologise for posting this amateur question. In my defence, I had just started a section a code when the grandchildren arrived and that put a sudden stop to it . . . . . :)