Source language: Translate to:

Difference between hours

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Difference between hours

Postby Alex » Fri Sep 23, 2011 7:26 am

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
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby Neosoft Support » Fri Sep 23, 2011 11:48 am

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.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5605
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Alex » Fri Sep 23, 2011 2:57 pm

Hi,

Thank you very much.


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

To late

Postby virger » Sat Sep 24, 2011 10:14 am

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"
User avatar
virger
 
Posts: 524
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby Alex » Mon Oct 03, 2011 11:05 am

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
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby smartmedia » Mon Oct 03, 2011 11:19 am

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
User avatar
smartmedia
 
Posts: 889
Joined: Fri Apr 01, 2005 6:50 am
Location: Hellas

Postby Alex » Mon Oct 03, 2011 11:58 am

hi,

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

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron