Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Control for spinner for time (not timer)
Message
From
09/04/2015 12:55:56
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
09/04/2015 12:00:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01617987
Message ID:
01618085
Views:
46
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 &&lnx 
>>
>>or
>>
clear
>>lnOldHour = 24
>>lnHours = 24
>>lnd = 1
>>FOR lnchange = 1 TO 25
>>lnOldHour = (lnOldHour+lnd)%lnHours
>>?lnOldHour
>>ENDFOR &&lnx 
>>
>>
>>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.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform