Page 1 of 1

Difference between hours

PostPosted: Fri Sep 23, 2011 7:26 am
by Alex
Hi,

I have 2 hours (6:09 and 8:34). How can I do that for example, an application doesn't have to run between 6:09 and 8:34? How can it knows? I tried:

Code: Select all
StrParse "[TextEntry15]" ":" "[yur]" "[rtrt]"

If "[Hour]" ">=" "[yur1]"
If "[Minute]" ">=" "[yur2]"

If "[TextEntry16]" "<>" ""
SearchStr ":" "[TextEntry16]" "[zie]" ""
If "[zie]" ">" "0"
StrParse "[TextEntry16]" ":" "[yure]" "[rtrte]"
If "[Hour]" "<=" "[yure1]"
If "[Minute]" "<=" "[yure2]"
.STOP APP
endif
endif
endif
endif
endif
else
.RUN APP
Endif
endif
endif
endif


Thanks


Alex

PostPosted: Fri Sep 23, 2011 11:48 am
by Neosoft Support
The easiest way to do this is convert all of the times to a number and compare them. For example:

Code: Select all
.convert first time to a number
StrParse "[TextEntry15]" ":" "[T]" "[Count]"
SetVar "[Time1]" "([T1]*3600)+([T2]*60)"

.convert second time to a number
StrParse "[TextEntry16]" ":" "[T]" "[Count]"
SetVar "[Time2]" "([T1]*3600)+([T2]*60)"

.convert current time to a number
StrParse "[Time24]" ":" "[T]" "[Count]"
SetVar "[Now]" "([T1]*3600)+([T2]*60)"

IfEx "[Now] >= [Time1] AND [Now] <= [Time2]"
  .RUN APP
Else
  .STOP APP
EndIf


This scripts requires all times to be in 24-hour format.

PostPosted: Fri Sep 23, 2011 2:57 pm
by Alex
Hi,

Thank you very much.


Alex

To late

PostPosted: Sat Sep 24, 2011 10:14 am
by virger
I used this code in a game

...Limit Times
setvar "[ti]" "06:09"
strparse "[ti]" ":" "[ti]" "[x]"

setvar "[tf]" "08:34"
strparse "[tf]" ":" "[tf]" "[x]"

...This Time
strparse "[Time24]" ":" "[Now]" "[x]"

...Calculate
setvar "[f1]" "[ti1]*60+[ti2]"
setvar "[f2]" "[tf1]*60+[tf2]"
setvar "[tl]" "[Now1]*60+[Now2]"

...Compare
ifex "[tl]>=[f1] AND [tl]<=[f2]"
alertbox "" "TIME TO STOP"
endif


BUENA SUERTE
DESDE COSTA RICA
AQUI "PURA VIDA"

PostPosted: Mon Oct 03, 2011 11:05 am
by Alex
Hi,

I have an other problem, because if I don't want that the application starts between 8:00 AM to 2:00 AM then it doesn't work because the application thing that is between 2:00 AM to 8:00 AM.

Is there any solution?

Thanks


Alex

PostPosted: Mon Oct 03, 2011 11:19 am
by smartmedia
Hi..

You can do it with 2 ways. First you can add an extra combo box with pm - am values and check if the hour is am or - pm. Or you can use only 24 hour clock. From 00:00 - 23:59

PostPosted: Mon Oct 03, 2011 11:58 am
by Alex
hi,

Yes, I use Time24, I just wrote AM and PM on the forum to explain.

Thanks


Alex