| View previous topic :: View next topic |
| Author |
Message |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 9:43 am Post subject: how to add time tu currnet time |
|
|
How to add time to currnet time
USE: Shutdown timer with Equal function |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Feb 10, 2005 1:42 pm Post subject: |
|
|
Could you be more specific about what you need or want to do? _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 3:46 pm Post subject: |
|
|
Example:
Time is 12:00 + preset for system shutdown is 30 minutes = 12:30
How to add time if current time is 12:00
%b = @fadd(@datetime(hh:nn),30) ???
Hard to explain
Some code...
:Half hourMENU
%b = ?
Dialog set,Status1,Shutdown timer set at: %B h
Dialog disable,Time
Dialog disable,BUTTON1
Dialog set,Time2, 30 minutes
goto loop
:Timer
%t = @datetime(hh:nn)
dialog set,time,%T
IF @Equal(%T,%B)
goto newloop
end |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Feb 10, 2005 4:14 pm Post subject: |
|
|
You need to break the time down into its separate componants.
| Code: |
%%timeNow = @datetime(hh|nn)
parse "%%hour;%%minutes",%%timeNow
info The time now is %%hour:%%minutes
info The time in 30 minutes is %%hour:@sum(%%minutes,30)
|
Since I'm not sure exactly what you're trying to do, this is all I can help
with. Hopefully this will help. _________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
kOt Contributor

Joined: 19 Jan 2004 Posts: 89 Location: Fyffe, AL
|
Posted: Thu Feb 10, 2005 5:20 pm Post subject: |
|
|
im not sure but i believe i seen a dll that could add time together. i cant recall the name but maybe someone else can.
I know i downloaded it from here though _________________ Visual Dialogscript 5 |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 6:35 pm Post subject: |
|
|
Yes almost perfect...
But if time is let say 12:45 i get 12:75 to high value for standard clock range...
:Half hourMENU
%%timeNow = @datetime(hh|nn)
parse "%%hour;%%minutes",%%timeNow
%b = %%hour:@sum(%%minutes,30)
Dialog set,Status1,Shutdown timer set at: %B h
Dialog disable,Time
Dialog disable,BUTTON1
Dialog set,Time2, 30 minutes
goto loop
Last edited by filip on Thu Feb 10, 2005 6:40 pm; edited 1 time in total |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Feb 10, 2005 6:38 pm Post subject: |
|
|
But @datetime without any format string argument returns a floating point number, which you can add to using @fadd, so all you need to know is the fractional value equivalent to 30 minutes. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 6:57 pm Post subject: |
|
|
Jules you are mathematics
What means fractional
like fragment or what
i dont come from english talking country |
|
| Back to top |
|
 |
ShinobiSoft Professional Member


Joined: 06 Nov 2002 Posts: 790 Location: Knoxville, Tn
|
Posted: Thu Feb 10, 2005 7:01 pm Post subject: |
|
|
I would simply add some error checking such as the following:
| Code: |
%%timeNow = @datetime(hh|nn)
parse "%%hour;%%minutes",%%timeNow
info The time now is %%hour:%%minutes
if @greater(@sum(%%minutes,30),59)
%%hour = @succ(%%hour)
%%minutes = @diff(@sum(%%minutes,30),60)
info The time in 30 minutes is %%hour:%%minutes
else
info The time in 30 minutes is %%hour:@sum(%%minutes,30)
end
|
_________________ Bill Weckel
ShinobiSoft Software
"The way is known to all, but not all know it." |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 7:20 pm Post subject: |
|
|
Thanks to all
im not finished yet
What if i use 1 hour or more
1 hour work but not always if time is 20:09 i get 21:9 (not 21:09)
2 hour dont work if time is 20:18 i get 21:78
:One hourMENU
%%timeNow = @datetime(hh|nn)
parse "%%hour;%%minutes",%%timeNow
if @greater(@sum(%%minutes,60),59)
%%hour = @succ(%%hour)
%%minutes = @diff(@sum(%%minutes,60),60)
%b = %%hour:%%minutes
else
%b = %%hour:@sum(%%minutes,60)
end
Dialog set,Status1,Shutdown timer set at: %B h
Dialog disable,Time
Dialog disable,BUTTON1
Dialog set,Time2, 1h
goto loop
:Two hoursMENU
%%timeNow = @datetime(hh|nn)
parse "%%hour;%%minutes",%%timeNow
if @greater(@sum(%%minutes,120),59)
%%hour = @succ(%%hour)
%%minutes = @diff(@sum(%%minutes,120),60)
%b = %%hour:%%minutes
else
%b = %%hour:@sum(%%minutes,120)
end
Dialog set,Status1,Shutdown timer set at: %B h
Dialog disable,Time
Dialog disable,BUTTON1
Dialog set,Time2, 2 h
goto loop |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu Feb 10, 2005 7:54 pm Post subject: |
|
|
@datetime() will return a floating point number in the format xxxxx.yyyyyy - where xxxxx is the date portion in raw form and yyyyyy is time in raw form.
in raw form, 24hours = 1.0, therefore 1 hour = @fdiv(1,24) and 1 minute = @fdiv(1,1440)
Using these figures you can add them to a raw datetime value and then convert that to hh:mm using @datetime(hh:mm,%%rawvalue)
Hope this helps...
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Thu Feb 10, 2005 8:33 pm Post subject: |
|
|
This dont work
(seconds must be off)
@datetime(hh|nn,%%rawvalue) not @datetime(hh:nn,%%rawvalue)
:Two hoursMENU
%%timeNow = @datetime(hh|nn,%%rawvalue)
%%rawvalue =@fdiv(1,24)
parse "%%hour;%%minutes",%%timeNow
if @greater(@sum(%%minutes,120),59)
%%hour = @succ(%%hour)
%%minutes = @diff(@sum(%%minutes,120),60)
%b = %%hour:%%minutes
else
%b = %%hour:@sum(%%minutes,120)
end
Dialog set,Status1,Shutdown timer set at: %B h
Dialog disable,Time
Dialog disable,BUTTON1
Dialog set,Time2, 2 h
goto loop |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Thu Feb 10, 2005 9:45 pm Post subject: |
|
|
Perhap this will help...
| Code: |
Title TimeTest
%%now = @datetime(hh:nn)
%%rawtime = @datetime()
%%rawhour = @fdiv(1,24)
%%rawminute = @fdiv(1,1440)
DIALOG CREATE,Timetest,-1,0,240,243
REM *** Modified by Dialog Designer on 2/10/05 - 13:40 ***
DIALOG ADD,SPIN,SPIN1,65,135,73,24,0|24,0,,CLICK
DIALOG ADD,SPIN,SPIN2,94,139,69,24,0|60,0,,CLICK
DIALOG ADD,TEXT,Time1,30,130,,,%%now
DIALOG ADD,TEXT,newtime1,142,139,,,%%now
DIALOG ADD,BUTTON,BUTTON1,184,94,64,24,ok
DIALOG ADD,TEXT,TEXT1,71,48,,,hours
DIALOG ADD,TEXT,TEXT2,103,51,,,minutes
DIALOG ADD,TEXT,TEXT3,32,42,,,Start time -
DIALOG ADD,TEXT,TEXT4,146,42,,,New time -
DIALOG SHOW
:Evloop
wait event
goto @event()
:SPIN1CLICK
:SPIN2CLICK
%h = @dlgtext(spin1)
%m = @dlgtext(spin2)
%%newhour = @fmul(%%rawhour,%h)
%%newminute = @fmul(%%rawminute,%m)
%%newrawtime = @fadd(%%rawtime,@fadd(%%newhour,%%newminute))
%%newtime = @datetime(hh:nn,%%newrawtime)
dialog set,newtime1,%%newtime
goto evloop
:BUTTON1BUTTON
:Close
exit
|
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Fri Feb 11, 2005 10:29 am Post subject: |
|
|
You could also use the DateTime.DLL which can add/subtract any time unit (IncTime function) and calculate
VDS date/time value from a specific date and time...
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Fri Feb 11, 2005 11:38 am Post subject: |
|
|
Thank you Hooligan
Your code fixed my:
Replace stupid input for time
Shutdown time Presets now working just fine
%K = @pred(%K) working (delay for shutdown)
Timer stable... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|