Leading zero with weeknumbers

Discuss RoboTask here
Post Reply
Rukbunker
Posts: 208
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Leading zero with weeknumbers

Post by Rukbunker »

Most likely an easy question for programmers, but hard for me ;)

I want to have a leading zero for weeknumbers if {WeekOfTheYear({Date})} < 10. I already tried to add a VB task and defining a local variable, called "Weeknummer". (Dutch for weeknumber).

IF {WeekOfTheYear({Date})} < 10 then Weeknummer = "0"+{WeekOfTheYear({Date})}
ELSE
Weeknummer = {WeekOfTheYear({Date})}


Can someone turn on the light on the end of the tunnel? I'm halfway! ;)
Oleg
Site Admin
Posts: 3105
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Leading zero with weeknumbers

Post by Oleg »

Look at the example below
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|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task72"
Hide=INTEGER|0
ID=INTEGER|169953253
LogOnAsUser=INTEGER|1
Name=STRING|"leading zero"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""WEEKNUMMER"" with value ""{WeekOfTheYear({Date})}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varname=STRING|"WEEKNUMMER"
varvalue=STRING|"{WeekOfTheYear({Date})}"

[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
operator=STRING|"5"
type=STRING|"1"
value1=STRING|"{Weeknummer}"
value2=STRING|"10"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""WEEKNUMMER"" with value ""0{Weeknummer}"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"WEEKNUMMER"
varvalue=STRING|"0{Weeknummer}"

[Actions\Action4]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Weeknummer = {Weeknummer}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"Weeknummer = {Weeknummer}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

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

Re: Leading zero with weeknumbers

Post by Rukbunker »

Yeehaa :) Many thanks! (And when I see the task, quite simple). You just need to know.
Post Reply