Round numbers or remove decimal places from variables

Discuss RoboTask here
Post Reply
Mikaelo
Posts: 2
Joined: Mon Dec 11, 2023 9:15 pm

Round numbers or remove decimal places from variables

Post by Mikaelo »

Please, how can I remove decimal places or round up/down variables?
Thanks, Michael
Oleg
Site Admin
Posts: 3110
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Round numbers or remove decimal places from variables

Post by Oleg »

You can use VB evaluate action (for example) with Round basic function

Also look at my example below. Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|327819672
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1476"
Hide=INTEGER|0
ID=INTEGER|-227308028
LogOnAsUser=INTEGER|1
Name=STRING|"Round the value"
OnErrorTaskID=INTEGER|0
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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""pi"" with value ""3.14159"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"pi"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"pi"
varvalue=STRING|"3.14159"

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

[Actions\Action2\Params]
_rt_variables_produced=STRING|"IntegerValue"
expression=STRING|"round({pi},0)"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"IntegerValue"

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

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"pi = {pi}"
msg1=STRING|"Rounded value = {IntegerValue}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Post Reply