Addition of SQL Results

Discuss RoboTask here
Post Reply
gremlin
Posts: 35
Joined: Sun Jan 08, 2023 3:13 pm

Addition of SQL Results

Post by gremlin »

Hy,
I read some numbers from a sql database and store these into variables.
Snipaste_2023-06-01_12-14-46.png
Snipaste_2023-06-01_12-14-46.png (14.38 KiB) Viewed 1323 times
This works fine.
The numebers are enclosed by "". So the variable show "773737,33333"
I would like to do a addition of these variables , then reduce by 10%.
When I try to do a addition the result looks like this : "773737,33333""3232,323" "5454,35454"
Snipaste_2023-06-01_12-17-40.png
Snipaste_2023-06-01_12-17-40.png (11.5 KiB) Viewed 1323 times
I think the "" would make a addition impossible. I had tried to replace these with a VB Script and the Replace command, but the Chr(34) isn`t allowed.
Can you give me a hint how to do this ?

Thanks

Steven
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Addition of SQL Results

Post by Oleg »

Function ADD accept as comma-separared string. So double-quote char is necessary.
Also I see that you miss round brackets ()
Function ADD can process only two values. So you can use such expression
{Add("{Add({Lager1},{Lager4})}",{lager5})}
Look at my example below:

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|"Task1430"
Hide=INTEGER|0
ID=INTEGER|550384746
LogOnAsUser=INTEGER|1
Name=STRING|"add values"
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
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager1"" with value """"773737,33333"""""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager1"
varvalue=STRING|"""773737,33333"""

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager4"" with value """"3232,323"""""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager4"
varvalue=STRING|"""3232,323"""

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager5"" with value """"5454,35454"""""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager5"
varvalue=STRING|"""5454,35454"""

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{Add(""{Add({Lager1},{Lager4})}"",{lager5})}"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{Add(""{Add({Lager1},{Lager4})}"",{lager5})}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Addition of SQL Results

Post by Oleg »

See below this example with VB evaluate
You must remove symbols " and replace , with .
VB language always uses dot (.) as decimal symbol.

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|"Task1431"
Hide=INTEGER|0
ID=INTEGER|1179493100
LogOnAsUser=INTEGER|1
Name=STRING|"add values with VB"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager1"" with value """"773737,33333"""""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager1"
varvalue=STRING|"""773737,33333"""

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

[Actions\Action10\Params]
expression=STRING|"{Lager1} + {Lager4} + {Lager5}"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"res"

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

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

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager4"" with value """"3232,323"""""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager4"
varvalue=STRING|"""3232,323"""

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""lager5"" with value """"5454,35454"""""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"lager5"
varvalue=STRING|"""5454,35454"""

[Actions\Action4]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{Lager1}"
substring=STRING|""""
variable=STRING|"Lager1"

[Actions\Action5]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"."
source=STRING|"{Lager1}"
substring=STRING|","
variable=STRING|"Lager1"

[Actions\Action6]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action6\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{Lager4}"
substring=STRING|""""
variable=STRING|"Lager4"

[Actions\Action7]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action7\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"."
source=STRING|"{Lager4}"
substring=STRING|","
variable=STRING|"Lager4"

[Actions\Action8]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
mode=STRING|"0"
source=STRING|"{Lager5}"
substring=STRING|""""
variable=STRING|"Lager5"

[Actions\Action9]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action9\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"."
source=STRING|"{Lager5}"
substring=STRING|","
variable=STRING|"Lager5"

Oleg Yershov
gremlin
Posts: 35
Joined: Sun Jan 08, 2023 3:13 pm

Re: Addition of SQL Results

Post by gremlin »

Ok, thank you very much.
Post Reply