Discuss RoboTask here
gremlin
Posts: 50 Joined: Sun Jan 08, 2023 3:13 pm
Post
by gremlin » Tue Nov 19, 2024 4:00 pm
Hy,
I try to remove a "," Symbol from a variable, but only when it´s the last character...
So i try with VBScript, but I get a error message from 'Left' Command ?
Do you have any idea ?
Code: Select all
rtVar = RoboTaskApp.ExpandText("{Material}")
If Left(RTVar,len(RTVar)-1) = "," then rtVar = Left(rtVar, Len(rtVar) - 1)
RoboTaskApp.SetUserVariable "Material", rtVar
Oleg
Site Admin
Posts: 3201 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Tue Nov 19, 2024 4:24 pm
Use this script
Code: Select all
rtVar = RoboTaskApp.ExpandText("{Material}")
If Right(RTVar,1) = "," then rtVar = Left(rtVar, Len(rtVar) - 1)
RoboTaskApp.SetUserVariable "Material", rtVar
also look at my example
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|601183744
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task132"
Hide=INTEGER|0
ID=INTEGER|-2091048688
LogOnAsUser=INTEGER|1
Name=STRING|"Remove last comma"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
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
Action4=FOLDER
Action5=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action1\Params]
_rt_variables_produced=STRING|"material"
delimiter_no=STRING|"0"
destvar=STRING|"material"
line0=STRING|"material, one"
line1=STRING|"material two,"
line2=STRING|"material three "
linecount=STRING|"3"
quote_char=STRING|"0"
sourcetext=STRING|"1"
strict_delim=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""oldmaterial"" with value ""{material}"""
Params=FOLDER
[Actions\Action2\Params]
_rt_variables_produced=STRING|"oldmaterial"
expand=STRING|"1"
linecount=STRING|"1"
varname=STRING|"oldmaterial"
varvalue=STRING|"{material}"
[Actions\Action3]
ActionID=STRING|"A_SCRIPT_VBSCRIPT"
Enabled=INTEGER|-1
Name=STRING|"VB Script"
Params=FOLDER
[Actions\Action3\Params]
expandvars=STRING|"0"
line00000000=STRING|"rtVar = RoboTaskApp.ExpandText(""{Material}"")"
line00000001=STRING|"'rtvar = ""material,"""
line00000002=STRING|"'LogMessage(Right(RTVar,1))"
line00000003=STRING|"'LogMessage(Left(RTVar,Len(rtVar) - 1))"
line00000005=STRING|"If Right(RTVar,1) = "","" then rtVar = Left(rtVar, Len(rtVar) - 1)"
line00000006=STRING|"RoboTaskApp.SetUserVariable ""Material"", rtVar"
line00000007=STRING|"'LogMessage(rtvar)"
linecount=STRING|"8"
savescript=STRING|"0"
[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{oldmaterial}"""
Params=FOLDER
[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{oldmaterial}"
msg1=STRING|"{material}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg Yershov
gremlin
Posts: 50 Joined: Sun Jan 08, 2023 3:13 pm
Post
by gremlin » Wed Nov 20, 2024 10:23 am
Great !
Thank you