VBScript Variables

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

VBScript Variables

Post by gremlin »

Hy,
any hint ? How can I use Robotask variable at VBScript and gice a result back to Robotask with a new Variable ?

I had tried much, but can´t get it work.

Thanks

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

Re: VBScript Variables

Post by Oleg »

Look at my small example (see 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|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1146"
Hide=INTEGER|0
ID=INTEGER|636456698
LogOnAsUser=INTEGER|1
Name=STRING|"Put variable to script and from script"
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 ""MyVar"" with value ""Hello World!!!"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"MyVar"
varvalue=STRING|"Hello World!!!"

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

[Actions\Action2\Params]
expandvars=STRING|"0"
line00000000=STRING|"RTVar = RoboTaskApp.ExpandText(""{MyVar}"")"
line00000001=STRING|"LogMessage(""Output from VBScript: "" + rtVar)"
line00000002=STRING|"rtVar = StrReverse(rtVar)"
line00000003=STRING|"RoboTaskApp.SetUserVariable ""MyVar"", rtvar"
linecount=STRING|"5"
savescript=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"Output from task: {MyVar}"
type=STRING|"3"

Oleg Yershov
Post Reply