I think that information is useful for other users.
So I publish my examples here.
RegExp match action saves some value into
EXPR variable only if expression is matched to your pattern. If it is not matched the action keeps the variable stays unchanged.
Look at my two examples
These examples test the line with
RegExp Match action in the loop.
Pay attention that 3 lines are matched but 4-th line is not
Look at this example . The variable
EXPR contains the previous value at last iteration
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1951268510
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task435"
Hide=INTEGER|0
ID=INTEGER|483472358
LogOnAsUser=INTEGER|1
Name=STRING|"mytest 1"
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_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action1\Params]
destvar=STRING|"SUBJ"
line0=STRING|"Alert on AUD/JPY"
line1=STRING|"Alert on GPB/CAD"
line2=STRING|"Alert on USD/JPY"
line3=STRING|"Hello world"
linecount=STRING|"4"
sourcetext=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER
[Actions\Action2\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{subj}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"Alert on (.+)$"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"
[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action3\Params]
message=STRING|"{Match}; {expr}; {Expr(1)}"
type=STRING|"3"
[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_CYCLIC"
Params=FOLDER
UniqueID=INTEGER|-1705898956
[Events\Event1\Params]
id=STRING|"KV3ANCUN"
interval=STRING|"1"
notsatrtatactivation=STRING|"0"
In order to avoid this just reset the value of
EXPR variable before
RegExp Match action (look at next example)
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1951268510
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task436"
Hide=INTEGER|0
ID=INTEGER|1251330488
LogOnAsUser=INTEGER|1
Name=STRING|"mytest 2"
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
Action5=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action1\Params]
destvar=STRING|"SUBJ"
line0=STRING|"Alert on AUD/JPY"
line1=STRING|"Alert on GPB/CAD"
line2=STRING|"Alert on USD/JPY"
line3=STRING|"Hello world"
linecount=STRING|"4"
sourcetext=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""EXPR"" with value """""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"EXPR"
[Actions\Action3]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER
[Actions\Action3\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{subj}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"Alert on (.+)$"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"1"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"match"
[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action4\Params]
message=STRING|"{Match}; {expr}; {Expr(1)}"
type=STRING|"3"
[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Events]
Event1=FOLDER
[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_CYCLIC"
Params=FOLDER
UniqueID=INTEGER|-1767274076
[Events\Event1\Params]
id=STRING|"KV3ANCUN"
interval=STRING|"1"
notsatrtatactivation=STRING|"0"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.