ring from 0 - 59,1-60
lnLimit = 60
lnStep=1
?'Start inc 0-59 dec 0-59 inc 1-60 dec 1-60'
FOR lnloop = -1 TO 60
?lnloop
??(lnloop+lnStep)%60,(lnloop+lnStep)%60,
??(lnloop+lnStep-1)%60+1,(lnloop+lnStep-1)%60+1
NEXT
24 hour clock runs from 0:00:00 to 23:59:59 anyway. This is rather simple
If you need a carry over (sec-> min, min --> hour, hour -> am / pm and so on) , then you need to do some boundary checks. But not the get the value itself. :)
The problem is the strange 1-12 1-12 notation where 12:59 means the next day
If on that 1-12 system, I would run 1-12,am-pm,min,sec.
ther boundary checks are a bit different but not that far away.
In the end the neat solution is transform the whole thing to seconds, do the change needed depending on the value changed, mod 86400 and transform back to time
:)
>Not sure how this would work when not using a 24 hour clock. I think you still have to have some sort of IF/ENDIF when rolling from 12:00 to 1:00.
>
>Albert
>
>
>>There is a lot of IF in the code to form a ring. Typical codemonkey approach. :)
>>
>>This could be done quicker with the following formula using modulo:
>>
>>
>>lnHours = 24
>>lnNewHour = (lnOldHour+lnChange)%lnHours
>>
>>try
>>
>>clear
>>lnOldHour = 24
>>lnHours = 24
>>lnd = 1
>>FOR lnchange = 1 TO 25
>>lnOldHour = (lnOldHour-lnd)%lnHours
>>?lnOldHour
>>ENDFOR
>>
>>or
>>
clear
>>lnOldHour = 24
>>lnHours = 24
>>lnd = 1
>>FOR lnchange = 1 TO 25
>>lnOldHour = (lnOldHour+lnd)%lnHours
>>?lnOldHour
>>ENDFOR
>>
>>
>>new you loop between 1 and 00
>>
>>lots of if less :)
>>
>>and even if somebody enters 55 -> the modulo will fit it.
>>
>>Lutz
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]