Logic Help Needed

Discuss RoboTask here
Post Reply
kunkel321
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

Logic Help Needed

Post by kunkel321 »

This Task is similar to the "time capture" one I posted a couple days ago. This one is a "date capture" Task. If anyone is willing to try it out... I'm stuck on the logic. I've tried the RegExes individually and they do work, it is the nested IF statement that doesn't seem to work.

Assign a hotkey to the script, then select a bit of text that contains a date, and activate the Task. The script essentially, looks for a date in the format of 3/31/2020. If that is not found, then it looks for one in the format March 31st. My script is finding the M-D-YYYY one, but it's not seeing the MMMM D one. Again I don't think it's the RegEx that is a problem. The entire second IF statement seems to be invisible.

Ideas what I'm doing wrong?

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|327331060
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task2"
Hide=INTEGER|0
ID=INTEGER|2102574156
LogOnAsUser=INTEGER|1
Name=STRING|"AppointmentGetter-Date"
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
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//Select some text on computer that has a date in it.//"
Params=FOLDER

[Actions\Action1\Params]
comment=STRING|"Select some text on computer that has a date in it.//"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action11]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//~~~ GET THE DATE as MMM D ~~~~//"
Params=FOLDER

[Actions\Action11\Params]
comment=STRING|"~~~ GET THE DATE as MMM D ~~~~//"

[Actions\Action12]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp reMonthDayDate Match"
Params=FOLDER

[Actions\Action12\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{haystack}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"\b((Jan|Feb)(ru(ary)?)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|(Sep(tem)?|Oct(o)?|Nov|Dec)(em)?(ber)?)\s?(?<!:)([1-2]?[0-9]|30|31)(st|nd|rd|th)?(?!:)\b"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"reMonthDayDate"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"

[Actions\Action13]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If reMonthDayDate <> """" Then"
Params=FOLDER

[Actions\Action13\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"reMonthDayDate(0)"

[Actions\Action14]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""reMonthDayDate was not blank."""
Params=FOLDER

[Actions\Action14\Params]
icon=STRING|"1"
msg0=STRING|"reMonthDayDate was not blank."
msg2=STRING|"var reMonthDayDate is {reMonthDayDate(0)}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action15]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""MYDATE"" with value ""{reMonthDayDate(0)}"""
Params=FOLDER

[Actions\Action15\Params]
expand=STRING|"0"
varname=STRING|"MYDATE"
varvalue=STRING|"{reMonthDayDate(0)}"

[Actions\Action16]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action17]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Niether RegEx was matched."""
Params=FOLDER

[Actions\Action17\Params]
icon=STRING|"1"
msg0=STRING|"Niether RegEx was matched."
msg2=STRING|"var myDate is {myDate}"
msg3=STRING|"var reNumDate is {reNumDate(0)}"
msg4=STRING|"var reMonthDayDate is {reMonthDayDate(0)}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action18]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action19]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_CLIPBOARD_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy"
Params=FOLDER

[Actions\Action2\Params]
mode=STRING|"1"

[Actions\Action20]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""var myDate is {myDate}"""
Params=FOLDER

[Actions\Action20\Params]
icon=STRING|"1"
msg0=STRING|"var myDate is {myDate}"
msg1=STRING|"var reNumDate is {reNumDate(0)}"
msg2=STRING|"var reMonthDayDate is {reMonthDayDate(0)}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_CLIPBOARD_GET"
Enabled=INTEGER|-1
Name=STRING|"Get Text"
Params=FOLDER

[Actions\Action3\Params]
variable=STRING|"haystack"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""RENUMDATE"" with value """""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"RENUMDATE"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REMONTHDAYDATE"" with value """""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"REMONTHDAYDATE"

[Actions\Action6]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//~~~ GET THE DATE as M/D/YY~~~~//"
Params=FOLDER

[Actions\Action6\Params]
comment=STRING|"~~~ GET THE DATE as M/D/YY~~~~//"

[Actions\Action7]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp reNumDate Match"
Params=FOLDER

[Actions\Action7\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{haystack}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"\b(([0-9]|10|11|12)[-./]([0-2]?[0-9])[-./](20)?[0-9][0-9])"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"reNumDate"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If reNumbDate <> """" Then"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"reNumDate(0)"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""MYDATE"" with value ""{reNumDate(0)}"""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"0"
varname=STRING|"MYDATE"
varvalue=STRING|"{reNumDate(0)}"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Name=STRING|"Shift+Ctrl+Alt+C"
Params=FOLDER
UniqueID=INTEGER|319807989

[Events\Event1\Params]
hotkey=STRING|"57411"

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

Re: Logic Help Needed

Post by Oleg »

Look at the step #7 (RegExp reNumDate Match)
You assign the search result to variable FOUND (true or false)

Look at the step #8 (If..Then)
So you must check variable FOUND (as boolean) here. If FOUND is false the variable reNumDate is undefined. It makes no sense to compare its value with any expression.

Maybe the problem is here
... but it's not seeing the MMMM D one...
Give me some examples of real expressions where you want extract the date. I think that you have constructed a VERY complex regular expression...
But, maybe it make sense.
Oleg Yershov
kunkel321
Posts: 30
Joined: Sun Mar 15, 2020 5:23 pm

Re: Logic Help Needed

Post by kunkel321 »

Thanks for the reply. I think I figured it out... I didn't have curly bracks {} on the First Operand of my IF statements. Fixing that took care of it. I did go ahead and change it so my IF statements are looking at the {found} variable though. Below is the script, with that one change. Some of the date formats that it will find are:
April 1st
Nov 13
Dec 1
Jan 2nd
1-1-2022
12-3-20
2/22/2022
3.1.20

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|327331060
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task2"
Hide=INTEGER|0
ID=INTEGER|2102574156
LogOnAsUser=INTEGER|1
Name=STRING|"AppointmentGetter-Date"
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
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//Select some text on computer that has a date in it.//"
Params=FOLDER

[Actions\Action1\Params]
comment=STRING|"Select some text on computer that has a date in it.//"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action11]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//~~~ GET THE DATE as MMM D ~~~~//"
Params=FOLDER

[Actions\Action11\Params]
comment=STRING|"~~~ GET THE DATE as MMM D ~~~~//"

[Actions\Action12]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp reMonthDayDate Match"
Params=FOLDER

[Actions\Action12\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{haystack}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"\b((Jan|Feb)(ru(ary)?)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|(Sep(tem)?|Oct(o)?|Nov|Dec)(em)?(ber)?)\s?(?<!:)([1-2]?[0-9]|30|31)(st|nd|rd|th)?(?!:)\b"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"reMonthDayDate"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"

[Actions\Action13]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If found = True"
Params=FOLDER

[Actions\Action13\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{found}"
value2=STRING|"True"

[Actions\Action14]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""MYDATE"" with value ""{reMonthDayDate(0)}"""
Params=FOLDER

[Actions\Action14\Params]
expand=STRING|"0"
varname=STRING|"MYDATE"
varvalue=STRING|"{reMonthDayDate(0)}"

[Actions\Action15]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action16]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Niether RegEx was matched."""
Params=FOLDER

[Actions\Action16\Params]
icon=STRING|"1"
msg0=STRING|"Niether RegEx was matched."
msg2=STRING|"var myDate is {myDate}"
msg3=STRING|"var reNumDate is {reNumDate(0)}"
msg4=STRING|"var reMonthDayDate is {reMonthDayDate(0)}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action17]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action18]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action19]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""var myDate is {myDate}"""
Params=FOLDER

[Actions\Action19\Params]
icon=STRING|"1"
msg0=STRING|"var myDate is {myDate}"
msg1=STRING|"var reNumDate is {reNumDate(0)}"
msg2=STRING|"var reMonthDayDate is {reMonthDayDate(0)}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_CLIPBOARD_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy"
Params=FOLDER

[Actions\Action2\Params]
mode=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_CLIPBOARD_GET"
Enabled=INTEGER|-1
Name=STRING|"Get Text"
Params=FOLDER

[Actions\Action3\Params]
variable=STRING|"haystack"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""RENUMDATE"" with value """""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"RENUMDATE"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""REMONTHDAYDATE"" with value """""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"REMONTHDAYDATE"

[Actions\Action6]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//~~~ GET THE DATE as M/D/YY~~~~//"
Params=FOLDER

[Actions\Action6\Params]
comment=STRING|"~~~ GET THE DATE as M/D/YY~~~~//"

[Actions\Action7]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp reNumDate Match"
Params=FOLDER

[Actions\Action7\Params]
anchored=STRING|"0"
case=STRING|"1"
extended=STRING|"0"
line00000000=STRING|"{haystack}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"\b(([0-9]|10|11|12)[-./]([0-2]?[0-9])[-./](20)?[0-9][0-9])"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"reNumDate"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If found = True"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{found}"
value2=STRING|"True"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""MYDATE"" with value ""{reNumDate(0)}"""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"0"
varname=STRING|"MYDATE"
varvalue=STRING|"{reNumDate(0)}"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_GENERAL_HOTKEY"
Name=STRING|"Shift+Ctrl+Alt+C"
Params=FOLDER
UniqueID=INTEGER|319807989

[Events\Event1\Params]
hotkey=STRING|"57411"

Post Reply