HOUR + 1

Discuss RoboTask here
Post Reply
bil24884
Posts: 2
Joined: Fri May 11, 2018 2:34 pm

HOUR + 1

Post by bil24884 »

I have playlist filenames that use date and hour such as Sat1200.alb.
Trying to write NEXT HOUR's playlist to a folder with a different name
Tried creating a variable {PFN} that equals next hour {Hour(+1)} but it does not work. It still shows THIS HOUR and not next hour. Is there an easy way to a variable = next hour instead of this hour?
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: HOUR + 1

Post by Oleg »

Look at my example
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1251730006
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task163"
Hide=INTEGER|0
ID=INTEGER|-121147657
LogOnAsUser=INTEGER|1
Name=STRING|"add hour"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""H"" with value ""{hours}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"H"
varvalue=STRING|"{hours}"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""h"""
Params=FOLDER

[Actions\Action2\Params]
incement=STRING|"1"
vaiable=STRING|"h"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""current hour = {hours}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"current hour = {hours}"
msg1=STRING|"next hour = {h}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

Oleg Yershov
bil24884
Posts: 2
Joined: Fri May 11, 2018 2:34 pm

Re: HOUR + 1

Post by bil24884 »

You made it so easy. Thank you so much for your help!
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: HOUR + 1

Post by Rukbunker »

Hey Oleg,

In regard to this question, I'm searching for a solution with does almost the same. When hours = 23 (in the example above) the increment will return 24, which (in my case) should be 00. The leading zero is important.

In the Demo task [DEMO] "TimeIncHours" custom function, the whole {DateTime} is used and will return it as well with the correct amount of hours. However, I only need the hours with the leading zero. The demo task does this part correct, but returns the whole date.

function TimeIncHours(tm, add)
TimeIncHours = DateAdd("h", CInt(add), CDate(tm))
end function

unnamed.jpg
unnamed.jpg (12.77 KiB) Viewed 2169 times
Due to the fact I am a VB / JS n00b, how can I (without using string / regex stuff) adjust the script so that this only returns the hours with a leading zero? The function DateAdd("h",1, Now()) does the same.


Edit
Hour(FormatDateTime(DateAdd("h",1, Now()+1),4)) - :shock: :shock: Did it solved it myself now? WOW! It looks promsising to say at least.
Edit 2:
No, the leading zero is missing. :x
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: HOUR + 1

Post by Oleg »

...how can I (without using string / regex stuff) adjust the script so that this only returns the hours with a leading zero?
Maybe this? Look at this example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1474"
Hide=INTEGER|0
ID=INTEGER|-1459948289
LogOnAsUser=INTEGER|1
Name=STRING|"[DEMO-modified] ""TimeIncHours"" custom function"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TM"" with value ""{DateTime}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"TM"
varvalue=STRING|"{DateTime}"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""DELTA"" with value ""15"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"DELTA"
varvalue=STRING|"15"

[Actions\Action3]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action3\Params]
expression=STRING|"TimeIncHours(""{tm}"", {delta})"
line00000000=STRING|"function TimeIncHours(tm, add)"
line00000001=STRING|"  TimeIncHours = DateAdd(""h"", CInt(add), CDate(tm))"
line00000002=STRING|"end function"
line00000004=STRING|"'logmessage(TimeIncHours(""10:22:35"", ""12""))"
linecount=STRING|"5"
loadfromfile=STRING|"1"
variable=STRING|"newTime"

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""TimeIncHours result:"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"TimeIncHours result:"
msg2=STRING|"Current time: {tm}"
msg3=STRING|"Delta: {delta}"
msg4=STRING|"New time: {NewTime}"
msg5=STRING|"Only time {Time({NewTime})}"
msg6=STRING|"Only hours {DateTimeToFormat({NewTime},hh)}"
msg7=STRING|"Hours and minutes {DateTimeToFormat({NewTime},hh:mm)}"
msgcount=STRING|"8"
playsound=STRING|"0"
showmessage=STRING|"1"

Oleg Yershov
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: HOUR + 1

Post by Rukbunker »

Yupz, ofcourse that works perfectly! Thanks.
Post Reply