How to use local variable in VB Evaluate expression?

Discuss RoboTask here
Post Reply
DanMcKinney
Posts: 7
Joined: Sun Aug 18, 2019 10:40 pm

How to use local variable in VB Evaluate expression?

Post by DanMcKinney »

I am trying to use VB Evaluate to calculate a simple expression that uses one of my local variables, called SF. I'm assigning the result to another local variable.

The equation is 0.02 * SF, but obviously SF doesn't work in the VB Evaluate expression box! How do I get my local variable into that expression? Is that accomplished through script?

I'll admit I know nothing about scripting. If someone could show my how this might work, I'd be grateful!
Oleg
Site Admin
Posts: 3004
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: How to use local variable in VB Evaluate expression?

Post by Oleg »

You must use {SF} string in your expression
The expression is: 0.02*{sf}
RoboTask replaces the string {SF} with the value of the variable SF

look at my example please
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|1360203151
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task154"
Hide=INTEGER|0
ID=INTEGER|116953570
LogOnAsUser=INTEGER|1
Name=STRING|"VB Evaluate"
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_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""SF"" with value ""2500"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"SF"
varvalue=STRING|"2500"

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

[Actions\Action2\Params]
expression=STRING|"0.02*{sf}"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"NewSF"

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

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Old value = {SF}"
msg1=STRING|"New Value = {NewSF}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
DanMcKinney
Posts: 7
Joined: Sun Aug 18, 2019 10:40 pm

Re: How to use local variable in VB Evaluate expression?

Post by DanMcKinney »

Oleg - Much appreciated! I love the product, by the way. I'm on the evaluation version now, but will definitely be purchasing the full version. Thanks again!
Post Reply